Merge pull request #6188 from jamessan/vim-7.4.2200

vim-patch:7.4.2200

Closes #5314
This commit is contained in:
James McCoy 2017-02-27 14:35:57 -05:00 committed by GitHub
commit d290c13421
8 changed files with 325 additions and 79 deletions

View File

@ -176,7 +176,7 @@ this won't happen: >
let otherDict.myFunction = myDict.myFunction let otherDict.myFunction = myDict.myFunction
call otherDict.myFunction() call otherDict.myFunction()
Here "self" will be "myDict", because it was bound explitly. Here "self" will be "myDict", because it was bound explicitly.
1.3 Lists ~ 1.3 Lists ~
@ -1820,19 +1820,19 @@ v:swapcommand Normal mode command to be executed after a file has been
example, when jumping to a tag the value is ":tag tagname\r". example, when jumping to a tag the value is ":tag tagname\r".
For ":edit +cmd file" the value is ":cmd\r". For ":edit +cmd file" the value is ":cmd\r".
*v:t_TYPE* *v:t_bool* *t_bool-varialble* *v:t_TYPE* *v:t_bool* *t_bool-variable*
v:t_bool Value of Boolean type. Read-only. See: |type()| v:t_bool Value of Boolean type. Read-only. See: |type()|
*v:t_dict* *t_dict-varialble* *v:t_dict* *t_dict-variable*
v:t_dict Value of Dictionary type. Read-only. See: |type()| v:t_dict Value of Dictionary type. Read-only. See: |type()|
*v:t_float* *t_float-varialble* *v:t_float* *t_float-variable*
v:t_float Value of Float type. Read-only. See: |type()| v:t_float Value of Float type. Read-only. See: |type()|
*v:t_func* *t_func-varialble* *v:t_func* *t_func-variable*
v:t_func Value of Funcref type. Read-only. See: |type()| v:t_func Value of Funcref type. Read-only. See: |type()|
*v:t_list* *t_list-varialble* *v:t_list* *t_list-variable*
v:t_list Value of List type. Read-only. See: |type()| v:t_list Value of List type. Read-only. See: |type()|
*v:t_number* *t_number-varialble* *v:t_number* *t_number-variable*
v:t_number Value of Number type. Read-only. See: |type()| v:t_number Value of Number type. Read-only. See: |type()|
*v:t_string* *t_string-varialble* *v:t_string* *t_string-variable*
v:t_string Value of String type. Read-only. See: |type()| v:t_string Value of String type. Read-only. See: |type()|
*v:termresponse* *termresponse-variable* *v:termresponse* *termresponse-variable*
@ -2046,11 +2046,11 @@ getftime({fname}) Number last modification time of file
getftype({fname}) String description of type of file {fname} getftype({fname}) String description of type of file {fname}
getline({lnum}) String line {lnum} of current buffer getline({lnum}) String line {lnum} of current buffer
getline({lnum}, {end}) List lines {lnum} to {end} of current buffer getline({lnum}, {end}) List lines {lnum} to {end} of current buffer
getloclist({nr}) List list of location list items getloclist({nr}[, {what}]) List list of location list items
getmatches() List list of current matches getmatches() List list of current matches
getpid() Number process ID of Vim getpid() Number process ID of Vim
getpos({expr}) List position of cursor, mark, etc. getpos({expr}) List position of cursor, mark, etc.
getqflist() List list of quickfix items getqflist([{what}]) List list of quickfix items
getreg([{regname} [, 1 [, {list}]]]) getreg([{regname} [, 1 [, {list}]]])
String or List contents of register String or List contents of register
getregtype([{regname}]) String type of register getregtype([{regname}]) String type of register
@ -2211,11 +2211,11 @@ setcharsearch({dict}) Dict set character search from {dict}
setcmdpos({pos}) Number set cursor position in command-line setcmdpos({pos}) Number set cursor position in command-line
setfperm({fname}, {mode} Number set {fname} file permissions to {mode} setfperm({fname}, {mode} Number set {fname} file permissions to {mode}
setline({lnum}, {line}) Number set line {lnum} to {line} setline({lnum}, {line}) Number set line {lnum} to {line}
setloclist({nr}, {list}[, {action}[, {title}]]) setloclist({nr}, {list}[, {action}[, {what}]])
Number modify location list using {list} Number modify location list using {list}
setmatches({list}) Number restore a list of matches setmatches({list}) Number restore a list of matches
setpos({expr}, {list}) Number set the {expr} position to {list} setpos({expr}, {list}) Number set the {expr} position to {list}
setqflist({list}[, {action}[, {title}]] setqflist({list}[, {action}[, {what}]]
Number modify quickfix list using {list} Number modify quickfix list using {list}
setreg({n}, {v}[, {opt}]) Number set register to value and type setreg({n}, {v}[, {opt}]) Number set register to value and type
settabvar({nr}, {varname}, {val}) set {varname} in tab page {nr} to {val} settabvar({nr}, {varname}, {val}) set {varname} in tab page {nr} to {val}
@ -2773,8 +2773,8 @@ col({expr}) The result is a Number, which is the byte index of the column
complete({startcol}, {matches}) *complete()* *E785* complete({startcol}, {matches}) *complete()* *E785*
Set the matches for Insert mode completion. Set the matches for Insert mode completion.
Can only be used in Insert mode. You need to use a mapping Can only be used in Insert mode. You need to use a mapping
with CTRL-R = |i_CTRL-R|. It does not work after CTRL-O or with CTRL-R = (see |i_CTRL-R|). It does not work after CTRL-O
with an expression mapping. or with an expression mapping.
{startcol} is the byte offset in the line where the completed {startcol} is the byte offset in the line where the completed
text start. The text up to the cursor is the original text text start. The text up to the cursor is the original text
that will be replaced by the matches. Use col('.') for an that will be replaced by the matches. Use col('.') for an
@ -4126,7 +4126,7 @@ getline({lnum} [, {end}])
< To get lines from another buffer see |getbufline()| < To get lines from another buffer see |getbufline()|
getloclist({nr}) *getloclist()* getloclist({nr},[, {what}]) *getloclist()*
Returns a list with all the entries in the location list for Returns a list with all the entries in the location list for
window {nr}. {nr} can be the window number or the window ID. window {nr}. {nr} can be the window number or the window ID.
When {nr} is zero the current window is used. When {nr} is zero the current window is used.
@ -4135,6 +4135,10 @@ getloclist({nr}) *getloclist()*
returned. For an invalid window number {nr}, an empty list is returned. For an invalid window number {nr}, an empty list is
returned. Otherwise, same as |getqflist()|. returned. Otherwise, same as |getqflist()|.
If the optional {what} dictionary argument is supplied, then
returns the items listed in {what} as a dictionary. Refer to
|getqflist()| for the supported items in {what}.
getmatches() *getmatches()* getmatches() *getmatches()*
Returns a |List| with all matches previously defined by Returns a |List| with all matches previously defined by
|matchadd()| and the |:match| commands. |getmatches()| is |matchadd()| and the |:match| commands. |getmatches()| is
@ -4184,7 +4188,7 @@ getpos({expr}) Get the position for {expr}. For possible values of {expr}
< Also see |getcurpos()| and |setpos()|. < Also see |getcurpos()| and |setpos()|.
getqflist() *getqflist()* getqflist([{what}]) *getqflist()*
Returns a list with all the current quickfix errors. Each Returns a list with all the current quickfix errors. Each
list item is a dictionary with these entries: list item is a dictionary with these entries:
bufnr number of buffer that has the file name, use bufnr number of buffer that has the file name, use
@ -4209,7 +4213,28 @@ getqflist() *getqflist()*
:for d in getqflist() :for d in getqflist()
: echo bufname(d.bufnr) ':' d.lnum '=' d.text : echo bufname(d.bufnr) ':' d.lnum '=' d.text
:endfor :endfor
<
If the optional {what} dictionary argument is supplied, then
returns only the items listed in {what} as a dictionary. The
following string items are supported in {what}:
nr get information for this quickfix list
title get list title
winid get window id (if opened)
all all of the above quickfix properties
Non-string items in {what} are ignored.
If "nr" is not present then the current quickfix list is used.
In case of error processing {what}, an empty dictionary is
returned.
The returned dictionary contains the following entries:
nr quickfix list number
title quickfix list title text
winid quickfix window id (if opened)
Examples: >
:echo getqflist({'all': 1})
:echo getqflist({'nr': 2, 'title': 1})
<
getreg([{regname} [, 1 [, {list}]]]) *getreg()* getreg([{regname} [, 1 [, {list}]]]) *getreg()*
The result is a String, which is the contents of register The result is a String, which is the contents of register
@ -4372,6 +4397,8 @@ glob2regpat({expr}) *glob2regpat()*
if filename =~ '^Make.*\.mak$' if filename =~ '^Make.*\.mak$'
< When {expr} is an empty string the result is "^$", match an < When {expr} is an empty string the result is "^$", match an
empty string. empty string.
Note that the result depends on the system. On MS-Windows
a backslash usually means a patch separator.
*globpath()* *globpath()*
globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]]) globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]])
@ -6466,18 +6493,20 @@ setline({lnum}, {text}) *setline()*
:endfor :endfor
< Note: The '[ and '] marks are not set. < Note: The '[ and '] marks are not set.
setloclist({nr}, {list} [, {action}[, {title}]]) *setloclist()* setloclist({nr}, {list} [, {action}[, {what}]]) *setloclist()*
Create or replace or add to the location list for window {nr}. Create or replace or add to the location list for window {nr}.
{nr} can be the window number or the window ID. {nr} can be the window number or the window ID.
When {nr} is zero the current window is used. When {nr} is zero the current window is used.
For a location list window, the displayed location list is For a location list window, the displayed location list is
modified. For an invalid window number {nr}, -1 is returned. If modified. For an invalid window number {nr}, -1 is returned.
{title} is given, it will be used to set |w:quickfix_title|
after opening the location window.
Otherwise, same as |setqflist()|. Otherwise, same as |setqflist()|.
Also see |location-list|. Also see |location-list|.
If the optional {what} dictionary argument is supplied, then
only the items listed in {what} are set. Refer to |setqflist()|
for the list of supported keys in {what}.
setmatches({list}) *setmatches()* setmatches({list}) *setmatches()*
Restores a list of matches saved by |getmatches()|. Returns 0 Restores a list of matches saved by |getmatches()|. Returns 0
if successful, otherwise -1. All current matches are cleared if successful, otherwise -1. All current matches are cleared
@ -6531,7 +6560,7 @@ setpos({expr}, {list})
|winrestview()|. |winrestview()|.
setqflist({list} [, {action}[, {title}]]) *setqflist()* setqflist({list} [, {action}[, {what}]]) *setqflist()*
Create or replace or add to the quickfix list using the items Create or replace or add to the quickfix list using the items
in {list}. Each item in {list} is a dictionary. in {list}. Each item in {list} is a dictionary.
Non-dictionary items in {list} are ignored. Each dictionary Non-dictionary items in {list} are ignored. Each dictionary
@ -6579,6 +6608,20 @@ setqflist({list} [, {action}[, {title}]]) *setqflist()*
If {title} is given, it will be used to set |w:quickfix_title| If {title} is given, it will be used to set |w:quickfix_title|
after opening the quickfix window. after opening the quickfix window.
If the optional {what} dictionary argument is supplied, then
only the items listed in {what} are set. The first {list}
argument is ignored. The following items can be specified in
{what}:
nr list number in the quickfix stack
title quickfix list title text
Unsupported keys in {what} are ignored.
If the "nr" item is not present, then the current quickfix list
is modified.
Examples: >
:call setqflist([], 'r', {'title': 'My search'})
:call setqflist([], 'r', {'nr': 2, 'title': 'Errors'})
<
Returns zero for success, -1 for failure. Returns zero for success, -1 for failure.
This function can be used to create a quickfix list This function can be used to create a quickfix list
@ -7901,6 +7944,10 @@ There are four types of features:
< Note that it's possible for patch 147 to be omitted even though 148 is < Note that it's possible for patch 147 to be omitted even though 148 is
included. included.
Hint: To find out if Vim supports backslashes in a file name (MS-Windows),
use: `if exists('+shellslash')`
acl Compiled with |ACL| support. acl Compiled with |ACL| support.
arabic Compiled with Arabic support |Arabic|. arabic Compiled with Arabic support |Arabic|.
autocmd Compiled with autocommand support. |autocommand| autocmd Compiled with autocommand support. |autocommand|

View File

@ -11065,6 +11065,37 @@ static void f_getline(typval_T *argvars, typval_T *rettv, FunPtr fptr)
get_buffer_lines(curbuf, lnum, end, retlist, rettv); get_buffer_lines(curbuf, lnum, end, retlist, rettv);
} }
static void get_qf_loc_list(int is_qf, win_T *wp, typval_T *what_arg,
typval_T *rettv)
{
if (what_arg->v_type == VAR_UNKNOWN) {
rettv_list_alloc(rettv);
if (is_qf || wp != NULL) {
(void)get_errorlist(wp, -1, rettv->vval.v_list);
}
} else {
rettv_dict_alloc(rettv);
if (is_qf || wp != NULL) {
if (what_arg->v_type == VAR_DICT) {
dict_T *d = what_arg->vval.v_dict;
if (d != NULL) {
get_errorlist_properties(wp, d, rettv->vval.v_dict);
}
} else {
EMSG(_(e_dictreq));
}
}
}
}
/// "getloclist()" function
static void f_getloclist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
win_T *wp = find_win_by_nr(&argvars[0], NULL);
get_qf_loc_list(false, wp, &argvars[1], rettv);
}
/* /*
* "getmatches()" function * "getmatches()" function
*/ */
@ -11166,20 +11197,10 @@ static void f_getpos(typval_T *argvars, typval_T *rettv, FunPtr fptr)
getpos_both(argvars, rettv, false); getpos_both(argvars, rettv, false);
} }
/* /// "getqflist()" functions
* "getqflist()" and "getloclist()" functions
*/
static void f_getqflist(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void f_getqflist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{ {
rettv_list_alloc(rettv); get_qf_loc_list(true, NULL, &argvars[0], rettv);
win_T *wp = NULL;
if (argvars[0].v_type != VAR_UNKNOWN) { /* getloclist() */
wp = find_win_by_nr(&argvars[0], NULL);
if (wp == NULL) {
return;
}
}
(void)get_errorlist(wp, rettv->vval.v_list);
} }
/// "getreg()" function /// "getreg()" function
@ -15721,7 +15742,7 @@ static void f_setline(typval_T *argvars, typval_T *rettv, FunPtr fptr)
/// Create quickfix/location list from VimL values /// Create quickfix/location list from VimL values
/// ///
/// Used by `setqflist()` and `setloclist()` functions. Accepts invalid /// Used by `setqflist()` and `setloclist()` functions. Accepts invalid
/// list_arg, action_arg and title_arg arguments in which case errors out, /// list_arg, action_arg and what_arg arguments in which case errors out,
/// including VAR_UNKNOWN parameters. /// including VAR_UNKNOWN parameters.
/// ///
/// @param[in,out] wp Window to create location list for. May be NULL in /// @param[in,out] wp Window to create location list for. May be NULL in
@ -15738,6 +15759,7 @@ static void set_qf_ll_list(win_T *wp, typval_T *args, typval_T *rettv)
char_u *title = NULL; char_u *title = NULL;
int action = ' '; int action = ' ';
rettv->vval.v_number = -1; rettv->vval.v_number = -1;
dict_T *d = NULL;
typval_T *list_arg = &args[0]; typval_T *list_arg = &args[0];
if (list_arg->v_type != VAR_LIST) { if (list_arg->v_type != VAR_LIST) {
@ -15765,12 +15787,18 @@ static void set_qf_ll_list(win_T *wp, typval_T *args, typval_T *rettv)
if (title_arg->v_type == VAR_UNKNOWN) { if (title_arg->v_type == VAR_UNKNOWN) {
// Option argument was not given. // Option argument was not given.
goto skip_args; goto skip_args;
} } else if (title_arg->v_type == VAR_STRING) {
title = get_tv_string_chk(title_arg); title = get_tv_string_chk(title_arg);
if (!title) { if (!title) {
// Type error. Error already printed by get_tv_string_chk(). // Type error. Error already printed by get_tv_string_chk().
return; return;
} }
} else if (title_arg->v_type == VAR_DICT) {
d = title_arg->vval.v_dict;
} else {
EMSG(_(e_dictreq));
return;
}
skip_args: skip_args:
if (!title) { if (!title) {
@ -15778,7 +15806,7 @@ skip_args:
} }
list_T *l = list_arg->vval.v_list; list_T *l = list_arg->vval.v_list;
if (l && set_errorlist(wp, l, action, title) == OK) { if (l && set_errorlist(wp, l, action, title, d) == OK) {
rettv->vval.v_number = 0; rettv->vval.v_number = 0;
} }
} }

View File

@ -126,11 +126,11 @@ return {
getftime={args=1}, getftime={args=1},
getftype={args=1}, getftype={args=1},
getline={args={1, 2}}, getline={args={1, 2}},
getloclist={args=1, func='f_getqflist'}, getloclist={args={1, 2}},
getmatches={}, getmatches={},
getpid={}, getpid={},
getpos={args=1}, getpos={args=1},
getqflist={}, getqflist={args={0, 1}},
getreg={args={0, 3}}, getreg={args={0, 3}},
getregtype={args={0, 1}}, getregtype={args={0, 1}},
gettabinfo={args={0, 1}}, gettabinfo={args={0, 1}},

View File

@ -2637,6 +2637,19 @@ static buf_T *qf_find_buf(qf_info_T *qi)
return NULL; return NULL;
} }
/// Update the w:quickfix_title variable in the quickfix/location list window
static void qf_update_win_titlevar(qf_info_T *qi)
{
win_T *win;
if ((win = qf_find_win(qi)) != NULL) {
win_T *curwin_save = curwin;
curwin = win;
qf_set_title_var(qi);
curwin = curwin_save;
}
}
/* /*
* Find the quickfix buffer. If it exists, update the contents. * Find the quickfix buffer. If it exists, update the contents.
*/ */
@ -2644,7 +2657,6 @@ static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
{ {
buf_T *buf; buf_T *buf;
win_T *win; win_T *win;
win_T *curwin_save;
aco_save_T aco; aco_save_T aco;
/* Check if a buffer for the quickfix list exists. Update it. */ /* Check if a buffer for the quickfix list exists. Update it. */
@ -2657,12 +2669,7 @@ static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
aucmd_prepbuf(&aco, buf); aucmd_prepbuf(&aco, buf);
} }
if ((win = qf_find_win(qi)) != NULL) { qf_update_win_titlevar(qi);
curwin_save = curwin;
curwin = win;
qf_set_title_var(qi);
curwin = curwin_save;
}
qf_fill_buffer(qi, buf, old_last); qf_fill_buffer(qi, buf, old_last);
@ -3849,10 +3856,9 @@ static void unload_dummy_buffer(buf_T *buf, char_u *dirname_start)
} }
} }
/* /// Add each quickfix error to list "list" as a dictionary.
* Add each quickfix error to list "list" as a dictionary. /// If qf_idx is -1, use the current list. Otherwise, use the specified list.
*/ int get_errorlist(win_T *wp, int qf_idx, list_T *list)
int get_errorlist(win_T *wp, list_T *list)
{ {
qf_info_T *qi = &ql_info; qf_info_T *qi = &ql_info;
dict_T *dict; dict_T *dict;
@ -3867,13 +3873,18 @@ int get_errorlist(win_T *wp, list_T *list)
return FAIL; return FAIL;
} }
if (qi->qf_curlist >= qi->qf_listcount if (qf_idx == -1) {
|| qi->qf_lists[qi->qf_curlist].qf_count == 0) qf_idx = qi->qf_curlist;
return FAIL; }
qfp = qi->qf_lists[qi->qf_curlist].qf_start; if (qf_idx >= qi->qf_listcount
for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; ++i) { || qi->qf_lists[qf_idx].qf_count == 0) {
/* Handle entries with a non-existing buffer number. */ return FAIL;
}
qfp = qi->qf_lists[qf_idx].qf_start;
for (i = 1; !got_int && i <= qi->qf_lists[qf_idx].qf_count; i++) {
// Handle entries with a non-existing buffer number.
bufnum = qfp->qf_fnum; bufnum = qfp->qf_fnum;
if (bufnum != 0 && (buflist_findnr(bufnum) == NULL)) if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
bufnum = 0; bufnum = 0;
@ -3904,22 +3915,91 @@ int get_errorlist(win_T *wp, list_T *list)
return OK; return OK;
} }
// Populate the quickfix list with the items supplied in the list /// Flags used by getqflist()/getloclist() to determine which fields to return.
// of dictionaries. "title" will be copied to w:quickfix_title enum {
// "action" is 'a' for add, 'r' for replace. Otherwise create a new list. QF_GETLIST_NONE = 0x0,
int set_errorlist(win_T *wp, list_T *list, int action, char_u *title) QF_GETLIST_TITLE = 0x1,
QF_GETLIST_ITEMS = 0x2,
QF_GETLIST_NR = 0x4,
QF_GETLIST_WINID = 0x8,
QF_GETLIST_ALL = 0xFF
};
/// Return quickfix/location list details (title) as a
/// dictionary. 'what' contains the details to return. If 'list_idx' is -1,
/// then current list is used. Otherwise the specified list is used.
int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict)
{
qf_info_T *qi = &ql_info;
if (wp != NULL) {
qi = GET_LOC_LIST(wp);
if (qi == NULL) {
return FAIL;
}
}
int status = OK;
dictitem_T *di;
int flags = QF_GETLIST_NONE;
int qf_idx = qi->qf_curlist; // default is the current list
if ((di = dict_find(what, (char_u *)"nr", -1)) != NULL) {
// Use the specified quickfix/location list
if (di->di_tv.v_type == VAR_NUMBER) {
qf_idx = di->di_tv.vval.v_number - 1;
if (qf_idx < 0 || qf_idx >= qi->qf_listcount) {
return FAIL;
}
flags |= QF_GETLIST_NR;
} else {
return FAIL;
}
}
if (dict_find(what, (char_u *)"all", -1) != NULL) {
flags |= QF_GETLIST_ALL;
}
if (dict_find(what, (char_u *)"title", -1) != NULL) {
flags |= QF_GETLIST_TITLE;
}
if (dict_find(what, (char_u *)"winid", -1) != NULL) {
flags |= QF_GETLIST_WINID;
}
if (flags & QF_GETLIST_TITLE) {
char_u *t = qi->qf_lists[qf_idx].qf_title;
if (t == NULL) {
t = (char_u *)"";
}
status = dict_add_nr_str(retdict, "title", 0L, t);
}
if ((status == OK) && (flags & QF_GETLIST_NR)) {
status = dict_add_nr_str(retdict, "nr", qf_idx + 1, NULL);
}
if ((status == OK) && (flags & QF_GETLIST_WINID)) {
win_T *win = qf_find_win(qi);
if (win != NULL) {
status = dict_add_nr_str(retdict, "winid", win->handle, NULL);
}
}
return status;
}
/// Add list of entries to quickfix/location list. Each list entry is
/// a dictionary with item information.
static int qf_add_entries(qf_info_T *qi, list_T *list, char_u *title,
int action)
{ {
listitem_T *li; listitem_T *li;
dict_T *d; dict_T *d;
qfline_T *old_last = NULL; qfline_T *old_last = NULL;
int retval = OK; int retval = OK;
qf_info_T *qi = &ql_info;
bool did_bufnr_emsg = false; bool did_bufnr_emsg = false;
if (wp != NULL) {
qi = ll_get_or_alloc_list(wp);
}
if (action == ' ' || qi->qf_curlist == qi->qf_listcount) { if (action == ' ' || qi->qf_curlist == qi->qf_listcount) {
// make place for a new list // make place for a new list
qf_new_list(qi, title); qf_new_list(qi, title);
@ -4010,6 +4090,60 @@ int set_errorlist(win_T *wp, list_T *list, int action, char_u *title)
return retval; return retval;
} }
static int qf_set_properties(qf_info_T *qi, dict_T *what)
{
dictitem_T *di;
int retval = FAIL;
int qf_idx = qi->qf_curlist; // default is the current list
if ((di = dict_find(what, (char_u *)"nr", -1)) != NULL) {
// Use the specified quickfix/location list
if (di->di_tv.v_type == VAR_NUMBER) {
qf_idx = di->di_tv.vval.v_number - 1;
if (qf_idx < 0 || qf_idx >= qi->qf_listcount) {
return FAIL;
}
} else {
return FAIL;
}
}
if ((di = dict_find(what, (char_u *)"title", -1)) != NULL) {
if (di->di_tv.v_type == VAR_STRING) {
xfree(qi->qf_lists[qf_idx].qf_title);
qi->qf_lists[qf_idx].qf_title = get_dict_string(what, "title", true);
if (qf_idx == qi->qf_curlist) {
qf_update_win_titlevar(qi);
}
retval = OK;
}
}
return retval;
}
// Populate the quickfix list with the items supplied in the list
// of dictionaries. "title" will be copied to w:quickfix_title
// "action" is 'a' for add, 'r' for replace. Otherwise create a new list.
int set_errorlist(win_T *wp, list_T *list, int action, char_u *title,
dict_T *what)
{
qf_info_T *qi = &ql_info;
int retval = OK;
if (wp != NULL) {
qi = ll_get_or_alloc_list(wp);
}
if (what != NULL) {
retval = qf_set_properties(qi, what);
} else {
retval = qf_add_entries(qi, list, title, action);
}
return retval;
}
/* /*
* ":[range]cbuffer [bufnr]" command. * ":[range]cbuffer [bufnr]" command.
* ":[range]caddbuffer [bufnr]" command. * ":[range]caddbuffer [bufnr]" command.

View File

@ -789,7 +789,7 @@ do_tag (
} }
vim_snprintf((char *)IObuff, IOSIZE, "ltag %s", tag); vim_snprintf((char *)IObuff, IOSIZE, "ltag %s", tag);
set_errorlist(curwin, list, ' ', IObuff); set_errorlist(curwin, list, ' ', IObuff, NULL);
list_free(list); list_free(list);
xfree(fname); xfree(fname);

View File

@ -1462,3 +1462,42 @@ func Test_duplicate_buf()
call delete('Xgrepthis') call delete('Xgrepthis')
endfunc endfunc
" Quickfix/Location list set/get properties tests
function Xproperty_tests(cchar)
call s:setup_commands(a:cchar)
" Error cases
call assert_fails('call g:Xgetlist(99)', 'E715:')
call assert_fails('call g:Xsetlist(99)', 'E714:')
call assert_fails('call g:Xsetlist([], "a", [])', 'E715:')
" Set and get the title
Xopen
wincmd p
call g:Xsetlist([{'filename':'foo', 'lnum':27}])
call g:Xsetlist([], 'a', {'title' : 'Sample'})
let d = g:Xgetlist({"title":1})
call assert_equal('Sample', d.title)
Xopen
call assert_equal('Sample', w:quickfix_title)
Xclose
" Invalid arguments
call assert_fails('call g:Xgetlist([])', 'E715')
call assert_fails('call g:Xsetlist([], "a", [])', 'E715')
let s = g:Xsetlist([], 'a', {'abc':1})
call assert_equal(-1, s)
call assert_equal({}, g:Xgetlist({'abc':1}))
if a:cchar == 'l'
call assert_equal({}, getloclist(99, ['title']))
endif
endfunction
function Test_qf_property()
call Xproperty_tests('c')
call Xproperty_tests('l')
endfunction

View File

@ -240,7 +240,7 @@ static int included_patches[] = {
// 2203 NA // 2203 NA
// 2202 NA // 2202 NA
2201, 2201,
// 2200, 2200,
// 2199 NA // 2199 NA
// 2198 NA // 2198 NA
2197, 2197,

View File

@ -27,20 +27,18 @@ describe('setqflist()', function()
setqflist({''}, 'r', 'foo') setqflist({''}, 'r', 'foo')
command('copen') command('copen')
eq(':foo', get_cur_win_var('quickfix_title')) eq(':foo', get_cur_win_var('quickfix_title'))
setqflist({''}, 'r', {['title'] = 'qf_title'})
eq('qf_title', get_cur_win_var('quickfix_title'))
end) end)
it('requires string or number for {title}', function() it('allows string {what} for backwards compatibility', function()
command('copen')
setqflist({}, 'r', '5') setqflist({}, 'r', '5')
command('copen')
eq(':5', get_cur_win_var('quickfix_title')) eq(':5', get_cur_win_var('quickfix_title'))
setqflist({}, 'r', 6) end)
eq(':6', get_cur_win_var('quickfix_title'))
local exc = exc_exec('call setqflist([], "r", function("function"))') it('requires a dict for {what}', function()
eq('Vim(call):E729: using Funcref as a String', exc) eq('Vim(call):E715: Dictionary required', exc_exec('call setqflist([], "r", function("function"))'))
exc = exc_exec('call setqflist([], "r", [])')
eq('Vim(call):E730: using List as a String', exc)
exc = exc_exec('call setqflist([], "r", {})')
eq('Vim(call):E731: using Dictionary as a String', exc)
end) end)
end) end)