1
0
forked from aniani/vim

patch 8.2.0933: 'quickfixtextfunc' does not get window ID of location list

Problem:    'quickfixtextfunc' does not get window ID of location list.
Solution:   Add "winid" to the dict argument. (Yegappan Lakshmanan,
            closes #6222)
This commit is contained in:
Bram Moolenaar
2020-06-08 19:20:27 +02:00
parent f154f3ab2c
commit 7ba5a7eff3
4 changed files with 25 additions and 9 deletions

View File

@@ -1953,6 +1953,9 @@ following fields:
quickfix set to 1 when called for a quickfix list and 0 when called for
a location list.
winid for a location list, set to the id of the window with the
location list. For a quickfix list, set to 0. Can be used in
getloclist() to get the location list entry.
id quickfix or location list identifier
idx index of the entry in the quickfix or location list

View File

@@ -175,7 +175,7 @@ static int qf_win_pos_update(qf_info_T *qi, int old_qf_index);
static win_T *qf_find_win(qf_info_T *qi);
static buf_T *qf_find_buf(qf_info_T *qi);
static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last);
static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last);
static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int qf_winid);
static buf_T *load_dummy_buffer(char_u *fname, char_u *dirname_start, char_u *resulting_dir);
static void wipe_dummy_buffer(buf_T *buf, char_u *dirname_start);
static void unload_dummy_buffer(buf_T *buf, char_u *dirname_start);
@@ -4189,7 +4189,7 @@ ex_copen(exarg_T *eap)
lnum = qfl->qf_index;
// Fill the buffer with the quickfix list.
qf_fill_buffer(qfl, curbuf, NULL);
qf_fill_buffer(qfl, curbuf, NULL, curwin->w_id);
decr_quickfix_busy();
@@ -4381,6 +4381,10 @@ qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
if (buf != NULL)
{
linenr_T old_line_count = buf->b_ml.ml_line_count;
int qf_winid = 0;
if (IS_LL_STACK(qi))
qf_winid = curwin->w_id;
if (old_last == NULL)
// set curwin/curbuf to buf and save a few things
@@ -4388,7 +4392,7 @@ qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
qf_update_win_titlevar(qi);
qf_fill_buffer(qf_get_curlist(qi), buf, old_last);
qf_fill_buffer(qf_get_curlist(qi), buf, old_last, qf_winid);
++CHANGEDTICK(buf);
if (old_last == NULL)
@@ -4415,7 +4419,8 @@ qf_buf_add_line(
buf_T *buf, // quickfix window buffer
linenr_T lnum,
qfline_T *qfp,
char_u *dirname)
char_u *dirname,
int qf_winid)
{
int len;
buf_T *errbuf;
@@ -4433,10 +4438,11 @@ qf_buf_add_line(
typval_T args[1];
dict_T *d;
// create 'info' dict argument
// create the dict argument
if ((d = dict_alloc_lock(VAR_FIXED)) == NULL)
return FAIL;
dict_add_number(d, "quickfix", (long)IS_QF_LIST(qfl));
dict_add_number(d, "winid", (long)qf_winid);
dict_add_number(d, "id", (long)qfl->qf_id);
dict_add_number(d, "idx", (long)(lnum + 1));
++d->dv_refcount;
@@ -4535,7 +4541,7 @@ qf_buf_add_line(
* ml_delete() is used and autocommands will be triggered.
*/
static void
qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last)
qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int qf_winid)
{
linenr_T lnum;
qfline_T *qfp;
@@ -4574,7 +4580,7 @@ qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last)
}
while (lnum < qfl->qf_count)
{
if (qf_buf_add_line(qfl, buf, lnum, qfp, dirname) == FAIL)
if (qf_buf_add_line(qfl, buf, lnum, qfp, dirname, qf_winid) == FAIL)
break;
++lnum;

View File

@@ -4822,7 +4822,7 @@ func Tqfexpr(info)
let qfl = getqflist({'id' : a:info.id, 'idx' : a:info.idx,
\ 'items' : 1}).items
else
let qfl = getloclist(0, {'id' : a:info.id, 'idx' : a:info.idx,
let qfl = getloclist(a:info.winid, {'id' : a:info.id, 'idx' : a:info.idx,
\ 'items' : 1}).items
endif
@@ -4863,7 +4863,7 @@ func Xtest_qftextfunc(cchar)
let qfl = getqflist({'id' : a:info.id, 'idx' : a:info.idx,
\ 'items' : 1}).items
else
let qfl = getloclist(0, {'id' : a:info.id, 'idx' : a:info.idx,
let qfl = getloclist(a:info.winid, {'id' : a:info.id, 'idx' : a:info.idx,
\ 'items' : 1}).items
endif
if empty(qfl)
@@ -4878,6 +4878,11 @@ func Xtest_qftextfunc(cchar)
call assert_equal('Line 10, Col 2', getline(1))
call assert_equal('Line 20, Col 4', getline(2))
Xclose
" Add entries to the list when the quickfix buffer is hidden
Xaddexpr ['F1:30:6:red']
Xwindow
call assert_equal('Line 30, Col 6', getline(3))
Xclose
call g:Xsetlist([], 'r', {'quickfixtextfunc' : ''})
set quickfixtextfunc&
delfunc PerQfText

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
933,
/**/
932,
/**/