Hi,
On Mon, Jul 18, 2016 at 2:11 PM, Bram Moolenaar <[email protected]> wrote:
>
> The number of commands and functions for quickfix functionality keeps
> growing. It would be good to reduce this a bit.
>
> getqflist() currently does not take an argument. It could use an
> argument to specify what to get, instead of the whole list.
> So how about passing a dictionary? One of the items could be to get the
> aux data instead of the list of errors.
>
> For setqflist() it's a bit more tricky, since it already has a second
> "action" argument. But we can add the dictionary as the third argument.
>
> Perhaps getting and setting the quickfix title would also fit in here?
> And it allows for the filtering that we had a patch for?
> Would be good to get an overview before making more changes.
>
I am attaching a patch to enhance the getqflist/getloclist() functions to
return the title string and the setqflist()/setloclist() functions to set
the title string.
After this patch is incorporated, it will be easy to add the additional
items (e.g. context, items, number, stack, etc.).
The getqflist/setqflist functions now accept an optional dictionary
parameter. The dictionary parameter specifies which items to get or set.
If the {dict} argument is specified, then the getqflist function returns a
dictionary.
- Yegappan
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 7b421aa..794a169 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -2079,11 +2079,11 @@ getftime({fname}) Number last
modification time of file
getftype({fname}) String description of type of file {fname}
getline({lnum}) String line {lnum} 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
getpid() Number process ID of Vim
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}]]])
String or List contents of register
getregtype([{regname}]) String type of register
@@ -2238,11 +2238,12 @@ setcharsearch({dict}) Dict set character
search from {dict}
setcmdpos({pos}) Number set cursor position in command-line
setfperm({fname}, {mode}) Number set {fname} file permissions to {mode}
setline({lnum}, {line}) Number set line {lnum} to {line}
-setloclist({nr}, {list}[, {action}])
+setloclist({nr}, {list}[, {action}[, {what}]])
Number modify location list using {list}
setmatches({list}) Number restore a list of matches
setpos({expr}, {list}) Number set the {expr} position to {list}
-setqflist({list}[, {action}]) Number modify quickfix list using {list}
+setqflist({list}[, {action}[, {what}]])
+ Number modify quickfix list using {list}
setreg({n}, {v}[, {opt}]) Number set register to value and type
settabvar({nr}, {varname}, {val}) none set {varname} in tab page {nr} to {val}
settabwinvar({tabnr}, {winnr}, {varname}, {val})
@@ -4275,7 +4276,7 @@ getline({lnum} [, {end}])
< 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
window {nr}. {nr} can be the window number or the window ID.
When {nr} is zero the current window is used.
@@ -4284,6 +4285,10 @@ getloclist({nr})
*getloclist()*
returned. For an invalid window number {nr}, an empty list is
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 keys in {what}.
+
getmatches() *getmatches()*
Returns a |List| with all matches previously defined by
|matchadd()| and the |:match| commands. |getmatches()| is
@@ -4334,7 +4339,7 @@ getpos({expr}) Get the position for {expr}. For
possible values of {expr}
< Also see |getcurpos()| and |setpos()|.
-getqflist() *getqflist()*
+getqflist([{what}]) *getqflist()*
Returns a list with all the current quickfix errors. Each
list item is a dictionary with these entries:
bufnr number of buffer that has the file name, use
@@ -4360,6 +4365,18 @@ getqflist()
*getqflist()*
: echo bufname(d.bufnr) ':' d.lnum '=' d.text
:endfor
+ If the optional {what} dictionary is argument is supplied, then
+ returns only the items listed in {what} as a dictionary. The
+ following keys are supported in {what}:
+ title get quickfix list title
+
+ The value of the key is ignored. Unsupported keys in {what} are
+ ignored. The returned dictionary contains the following entries:
+ title quickfix list title text
+
+ Example:>
+ :echo getqflist({'title':1})
+<
getreg([{regname} [, 1 [, {list}]]]) *getreg()*
The result is a String, which is the contents of register
@@ -6496,7 +6513,7 @@ setline({lnum}, {text})
*setline()*
:endfor
< Note: The '[ and '] marks are not set.
-setloclist({nr}, {list} [, {action}]) *setloclist()*
+setloclist({nr}, {list} [, {action}[, {what}]) *setloclist()*
Create or replace or add to the location list for window {nr}.
{nr} can be the window number or the window ID.
When {nr} is zero the current window is used.
@@ -6506,6 +6523,10 @@ setloclist({nr}, {list} [, {action}])
*setloclist()*
Otherwise, same as |setqflist()|.
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()*
Restores a list of matches saved by |getmatches()|. Returns 0
if successful, otherwise -1. All current matches are cleared
@@ -6558,8 +6579,7 @@ setpos({expr}, {list})
also set the preferred column. Also see the "curswant" key in
|winrestview()|.
-
-setqflist({list} [, {action}]) *setqflist()*
+setqflist({list} [, {action}[, {what}]]) *setqflist()*
Create or replace or add to the quickfix list using the items
in {list}. Each item in {list} is a dictionary.
Non-dictionary items in {list} are ignored. Each dictionary
@@ -6604,6 +6624,17 @@ setqflist({list} [, {action}])
*setqflist()*
If {action} is not present or is set to ' ', then a new list
is created.
+ 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}:
+
+ title quickfix list title text.
+
+ To change the title for the current list, use 'a' as {action}.
+ Unsupported keys in {what} are ignored. Example:
+ :call setqflist([], 'a', {'title':'My search'})
+<
Returns zero for success, -1 for failure.
This function can be used to create a quickfix list
diff --git a/src/Makefile b/src/Makefile
index 001f87a..eac4340 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -567,6 +567,7 @@ CClink = $(CC)
# statically linked executable.
# When not defined, configure will try to use -O2 -g for gcc and -O for cc.
#CFLAGS = -g
+CFLAGS = -g -Wall -Wpedantic
#CFLAGS = -O
# Optimization limits - depends on the compiler. Automatic check in configure
@@ -658,7 +659,7 @@ LINT_OPTIONS = -beprxzF
# address sanitizer or with the undefined sanitizer. Works with gcc and
# clang. May make Vim twice as slow. Errors reported on stderr.
# More at: https://code.google.com/p/address-sanitizer/
-#SANITIZER_CFLAGS = -g -O0 -fsanitize=address -fno-omit-frame-pointer
+SANITIZER_CFLAGS = -g -O0 -fsanitize=address -fno-omit-frame-pointer
#SANITIZER_CFLAGS = -g -O0 -fsanitize=undefined -fno-omit-frame-pointer
SANITIZER_LIBS = $(SANITIZER_CFLAGS)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index ae17038..586c6da 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -170,6 +170,7 @@ static void f_getfsize(typval_T *argvars, typval_T *rettv);
static void f_getftime(typval_T *argvars, typval_T *rettv);
static void f_getftype(typval_T *argvars, typval_T *rettv);
static void f_getline(typval_T *argvars, typval_T *rettv);
+static void f_getloclist(typval_T *argvars UNUSED, typval_T *rettv UNUSED);
static void f_getmatches(typval_T *argvars, typval_T *rettv);
static void f_getpid(typval_T *argvars, typval_T *rettv);
static void f_getcurpos(typval_T *argvars, typval_T *rettv);
@@ -586,11 +587,11 @@ static struct fst
{"getftime", 1, 1, f_getftime},
{"getftype", 1, 1, f_getftype},
{"getline", 1, 2, f_getline},
- {"getloclist", 1, 1, f_getqflist},
+ {"getloclist", 1, 2, f_getloclist},
{"getmatches", 0, 0, f_getmatches},
{"getpid", 0, 0, f_getpid},
{"getpos", 1, 1, f_getpos},
- {"getqflist", 0, 0, f_getqflist},
+ {"getqflist", 0, 1, f_getqflist},
{"getreg", 0, 3, f_getreg},
{"getregtype", 0, 1, f_getregtype},
{"gettabvar", 2, 3, f_gettabvar},
@@ -736,10 +737,10 @@ static struct fst
{"setcmdpos", 1, 1, f_setcmdpos},
{"setfperm", 2, 2, f_setfperm},
{"setline", 2, 2, f_setline},
- {"setloclist", 2, 3, f_setloclist},
+ {"setloclist", 2, 4, f_setloclist},
{"setmatches", 1, 1, f_setmatches},
{"setpos", 2, 2, f_setpos},
- {"setqflist", 1, 2, f_setqflist},
+ {"setqflist", 1, 3, f_setqflist},
{"setreg", 2, 3, f_setreg},
{"settabvar", 3, 3, f_settabvar},
{"settabwinvar", 4, 4, f_settabwinvar},
@@ -4460,6 +4461,42 @@ f_getline(typval_T *argvars, typval_T *rettv)
}
/*
+ * "getloclist()" function
+ */
+ static void
+f_getloclist(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
+{
+#ifdef FEAT_QUICKFIX
+ win_T *wp;
+#endif
+
+#ifdef FEAT_QUICKFIX
+ wp = find_win_by_nr(&argvars[0], NULL);
+
+ if (argvars[1].v_type == VAR_UNKNOWN)
+ {
+ if (rettv_list_alloc(rettv) == OK && wp != NULL)
+ (void)get_errorlist(wp, -1, rettv->vval.v_list);
+ }
+ else
+ {
+ if (rettv_dict_alloc(rettv) == OK && wp != NULL)
+ {
+ if (argvars[1].v_type == VAR_DICT)
+ {
+ dict_T *d = argvars[1].vval.v_dict;
+ if (d != NULL)
+ get_errorlist_info(wp, argvars[1].vval.v_dict, -1,
+ rettv->vval.v_dict);
+ }
+ else
+ EMSG(_(e_dictreq));
+ }
+ }
+#endif
+}
+
+/*
* "getmatches()" function
*/
static void
@@ -4596,27 +4633,30 @@ f_getpos(typval_T *argvars, typval_T *rettv)
}
/*
- * "getqflist()" and "getloclist()" functions
+ * "getqflist()" function
*/
static void
f_getqflist(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
#ifdef FEAT_QUICKFIX
- win_T *wp;
-#endif
-
-#ifdef FEAT_QUICKFIX
- if (rettv_list_alloc(rettv) == OK)
+ if (argvars[0].v_type == VAR_UNKNOWN)
{
- wp = NULL;
- if (argvars[0].v_type != VAR_UNKNOWN) /* getloclist() */
+ if (rettv_list_alloc(rettv) == OK)
+ (void)get_errorlist(NULL, -1, rettv->vval.v_list);
+ }
+ else
+ {
+ if (rettv_dict_alloc(rettv) == OK)
{
- wp = find_win_by_nr(&argvars[0], NULL);
- if (wp == NULL)
- return;
+ if (argvars[0].v_type == VAR_DICT)
+ {
+ dict_T *d = argvars[0].vval.v_dict;
+ if (d != NULL)
+ get_errorlist_info(NULL, d, -1, rettv->vval.v_dict);
+ }
+ else
+ EMSG(_(e_dictreq));
}
-
- (void)get_errorlist(wp, rettv->vval.v_list);
}
#endif
}
@@ -9454,7 +9494,7 @@ f_setline(typval_T *argvars, typval_T *rettv)
appended_lines_mark(lcount, added);
}
-static void set_qf_ll_list(win_T *wp, typval_T *list_arg, typval_T
*action_arg, typval_T *rettv);
+static void set_qf_ll_list(win_T *wp, typval_T *list_arg, typval_T
*action_arg, typval_T *what_arg, typval_T *rettv);
/*
* Used by "setqflist()" and "setloclist()" functions
@@ -9464,6 +9504,7 @@ set_qf_ll_list(
win_T *wp UNUSED,
typval_T *list_arg UNUSED,
typval_T *action_arg UNUSED,
+ typval_T *what_arg UNUSED,
typval_T *rettv)
{
#ifdef FEAT_QUICKFIX
@@ -9480,6 +9521,7 @@ set_qf_ll_list(
else
{
list_T *l = list_arg->vval.v_list;
+ dict_T *d = NULL;
if (action_arg->v_type == VAR_STRING)
{
@@ -9496,8 +9538,11 @@ set_qf_ll_list(
else
EMSG(_(e_stringreq));
+ if (what_arg != NULL && what_arg->v_type == VAR_DICT)
+ d = what_arg->vval.v_dict;
+
if (l != NULL && action && set_errorlist(wp, l, action,
- (char_u *)(wp == NULL ? "setqflist()" : "setloclist()")) == OK)
+ (char_u *)(wp == NULL ? "setqflist()" : "setloclist()"), d) == OK)
rettv->vval.v_number = 0;
}
#endif
@@ -9515,7 +9560,15 @@ f_setloclist(typval_T *argvars, typval_T *rettv)
win = find_win_by_nr(&argvars[0], NULL);
if (win != NULL)
- set_qf_ll_list(win, &argvars[1], &argvars[2], rettv);
+ {
+ if (argvars[2].v_type == VAR_UNKNOWN ||
+ argvars[3].v_type == VAR_UNKNOWN)
+ set_qf_ll_list(win, &argvars[1], &argvars[2], NULL, rettv);
+ else if (argvars[3].v_type == VAR_DICT)
+ set_qf_ll_list(win, &argvars[1], &argvars[2], &argvars[3], rettv);
+ else
+ EMSG(_(e_dictreq));
+ }
}
/*
@@ -9681,7 +9734,13 @@ f_setpos(typval_T *argvars, typval_T *rettv)
static void
f_setqflist(typval_T *argvars, typval_T *rettv)
{
- set_qf_ll_list(NULL, &argvars[0], &argvars[1], rettv);
+ rettv->vval.v_number = -1;
+ if (argvars[1].v_type == VAR_UNKNOWN || argvars[2].v_type == VAR_UNKNOWN)
+ set_qf_ll_list(NULL, &argvars[0], &argvars[1], NULL, rettv);
+ else if (argvars[2].v_type == VAR_DICT)
+ set_qf_ll_list(NULL, &argvars[0], &argvars[1], &argvars[2], rettv);
+ else
+ EMSG(_(e_dictreq));
}
/*
diff --git a/src/proto/quickfix.pro b/src/proto/quickfix.pro
index 02c2d98..6aa169e 100644
--- a/src/proto/quickfix.pro
+++ b/src/proto/quickfix.pro
@@ -27,8 +27,9 @@ void ex_cnext(exarg_T *eap);
void ex_cfile(exarg_T *eap);
void ex_vimgrep(exarg_T *eap);
char_u *skip_vimgrep_pat(char_u *p, char_u **s, int *flags);
-int get_errorlist(win_T *wp, list_T *list);
-int set_errorlist(win_T *wp, list_T *list, int action, char_u *title);
+int get_errorlist_info(win_T *wp, dict_T *what, int qf_idx, dict_T *retdict);
+int get_errorlist(win_T *wp, int qf_idx, list_T *list);
+int set_errorlist(win_T *wp, list_T *list, int action, char_u *title, dict_T
*what);
void ex_cbuffer(exarg_T *eap);
void ex_cexpr(exarg_T *eap);
void ex_helpgrep(exarg_T *eap);
diff --git a/src/quickfix.c b/src/quickfix.c
index b607170..c190df8 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -3151,6 +3151,24 @@ qf_find_buf(qf_info_T *qi)
}
/*
+ * 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;
+ win_T *curwin_save;
+
+ if ((win = qf_find_win(qi)) != NULL)
+ {
+ curwin_save = curwin;
+ curwin = win;
+ qf_set_title_var(qi);
+ curwin = curwin_save;
+ }
+}
+
+/*
* Find the quickfix buffer. If it exists, update the contents.
*/
static void
@@ -3158,7 +3176,6 @@ qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
{
buf_T *buf;
win_T *win;
- win_T *curwin_save;
aco_save_T aco;
/* Check if a buffer for the quickfix list exists. Update it. */
@@ -3171,13 +3188,7 @@ qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
/* set curwin/curbuf to buf and save a few things */
aucmd_prepbuf(&aco, buf);
- if ((win = qf_find_win(qi)) != NULL)
- {
- curwin_save = curwin;
- curwin = win;
- qf_set_title_var(qi);
- curwin = curwin_save;
- }
+ qf_update_win_titlevar(qi);
qf_fill_buffer(qi, buf, old_last);
@@ -4542,9 +4553,10 @@ unload_dummy_buffer(buf_T *buf, char_u *dirname_start)
#if defined(FEAT_EVAL) || defined(PROTO)
/*
* 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, list_T *list)
+get_errorlist(win_T *wp, int qf_idx, list_T *list)
{
qf_info_T *qi = &ql_info;
dict_T *dict;
@@ -4560,12 +4572,15 @@ get_errorlist(win_T *wp, list_T *list)
return FAIL;
}
- if (qi->qf_curlist >= qi->qf_listcount
- || qi->qf_lists[qi->qf_curlist].qf_count == 0)
+ if (qf_idx == -1)
+ qf_idx = qi->qf_curlist;
+
+ if (qf_idx >= qi->qf_listcount
+ || qi->qf_lists[qf_idx].qf_count == 0)
return FAIL;
- qfp = qi->qf_lists[qi->qf_curlist].qf_start;
- for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; ++i)
+ 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;
@@ -4600,54 +4615,78 @@ get_errorlist(win_T *wp, list_T *list)
}
/*
- * 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.
+ * 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
-set_errorlist(
- win_T *wp,
- list_T *list,
- int action,
- char_u *title)
+get_errorlist_info(win_T *wp, dict_T *what, int qf_idx, dict_T *retdict)
{
- listitem_T *li;
- dict_T *d;
- char_u *filename, *pattern, *text, *type;
- int bufnum;
- long lnum;
- int col, nr;
- int vcol;
-#ifdef FEAT_WINDOWS
- qfline_T *old_last = NULL;
-#endif
- int valid, status;
- int retval = OK;
qf_info_T *qi = &ql_info;
- int did_bufnr_emsg = FALSE;
+ int status = FAIL;
if (wp != NULL)
{
- qi = ll_get_or_alloc_list(wp);
+ qi = GET_LOC_LIST(wp);
if (qi == NULL)
return FAIL;
}
- if (action == ' ' || qi->qf_curlist == qi->qf_listcount)
- /* make place for a new list */
- qf_new_list(qi, title);
-#ifdef FEAT_WINDOWS
- else if (action == 'a' && qi->qf_lists[qi->qf_curlist].qf_count > 0)
- /* Adding to existing list, use last entry. */
- old_last = qi->qf_lists[qi->qf_curlist].qf_last;
-#endif
- else if (action == 'r')
+ if (qf_idx == -1)
+ qf_idx = qi->qf_curlist;
+
+ if (dict_find(what, (char_u *)"title", -1) != NULL)
{
- qf_free(qi, qi->qf_curlist);
- qf_store_title(qi, title);
+ char_u *t;
+ t = qi->qf_lists[qf_idx].qf_title;
+ if (t == NULL)
+ t = (char_u *)"";
+ status = dict_add_nr_str(retdict, "title", 0L, t);
}
- for (li = list->lv_first; li != NULL; li = li->li_next)
+ return status;
+}
+
+ static int
+qf_set_properties(qf_info_T *qi, dict_T *what, int append, qfline_T *old_last)
+{
+ dictitem_T *di;
+ int retval = FAIL;
+
+ if ((di = dict_find(what, (char_u *)"title", -1)) != NULL)
+ {
+ if (di->di_tv.v_type == VAR_STRING)
+ {
+ vim_free(qi->qf_lists[qi->qf_curlist].qf_title);
+ qi->qf_lists[qi->qf_curlist].qf_title =
+ get_dict_string(what, (char_u *)"title", TRUE);
+ qf_update_win_titlevar(qi);
+ retval = OK;
+ }
+ }
+
+ return retval;
+}
+
+/*
+ * 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 *l, int append, qfline_T *old_last)
+{
+ listitem_T *li;
+ dict_T *d;
+ char_u *filename, *pattern, *text, *type;
+ int bufnum;
+ long lnum;
+ int col, nr;
+ int vcol;
+ int valid, status;
+ int did_bufnr_emsg = FALSE;
+ int retval = OK;
+
+ for (li = l->lv_first; li != NULL; li = li->li_next)
{
if (li->li_tv.v_type != VAR_DICT)
continue; /* Skip non-dict items */
@@ -4715,7 +4754,7 @@ set_errorlist(
qi->qf_lists[qi->qf_curlist].qf_nonevalid = TRUE;
else
qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
- if (action != 'a') {
+ if (!append) {
qi->qf_lists[qi->qf_curlist].qf_ptr =
qi->qf_lists[qi->qf_curlist].qf_start;
if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
@@ -4729,6 +4768,55 @@ set_errorlist(
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)
+{
+#ifdef FEAT_WINDOWS
+ qfline_T *old_last = NULL;
+#endif
+ int retval = OK;
+ qf_info_T *qi = &ql_info;
+
+ if (wp != NULL)
+ {
+ qi = ll_get_or_alloc_list(wp);
+ if (qi == NULL)
+ return FAIL;
+ }
+
+ if (action == ' ' || qi->qf_curlist == qi->qf_listcount)
+ /* make place for a new list */
+ qf_new_list(qi, title);
+#ifdef FEAT_WINDOWS
+ else if (action == 'a' && qi->qf_lists[qi->qf_curlist].qf_count > 0)
+ /* Adding to existing list, use last entry. */
+ old_last = qi->qf_lists[qi->qf_curlist].qf_last;
+#endif
+ else if (action == 'r')
+ {
+ qf_free(qi, qi->qf_curlist);
+ qf_store_title(qi, title);
+ }
+
+ if (what != NULL)
+ retval = qf_set_properties(qi, what, (action == 'a'), old_last);
+ else
+ retval = qf_add_entries(qi, list, (action == 'a'), old_last);
+
+ return retval;
+}
#endif
/*
diff --git a/src/tag.c b/src/tag.c
index cfc2b51..e388a43 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -916,7 +916,7 @@ do_tag(
}
vim_snprintf((char *)IObuff, IOSIZE, "ltag %s", tag);
- set_errorlist(curwin, list, ' ', IObuff);
+ set_errorlist(curwin, list, ' ', IObuff, NULL);
list_free(list);
vim_free(fname);
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index e79315b..6e38bbd 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -1504,3 +1504,37 @@ func Test_duplicate_buf()
call delete('Xgrepthis')
endfunc
+
+" Quickfix/Location list title text test
+function Xtitle_set_Tests(cchar)
+ call s:setup_commands(a:cchar)
+
+ " 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':1}))
+ endif
+endfunction
+
+function Test_set_title()
+ call Xtitle_set_Tests('c')
+ call Xtitle_set_Tests('l')
+endfunction