Skip to content

Commit 7ba5a7e

Browse files
committed
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)
1 parent f154f3a commit 7ba5a7e

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

runtime/doc/quickfix.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,9 @@ following fields:
19531953

19541954
quickfix set to 1 when called for a quickfix list and 0 when called for
19551955
a location list.
1956+
winid for a location list, set to the id of the window with the
1957+
location list. For a quickfix list, set to 0. Can be used in
1958+
getloclist() to get the location list entry.
19561959
id quickfix or location list identifier
19571960
idx index of the entry in the quickfix or location list
19581961

src/quickfix.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ static int qf_win_pos_update(qf_info_T *qi, int old_qf_index);
175175
static win_T *qf_find_win(qf_info_T *qi);
176176
static buf_T *qf_find_buf(qf_info_T *qi);
177177
static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last);
178-
static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last);
178+
static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int qf_winid);
179179
static buf_T *load_dummy_buffer(char_u *fname, char_u *dirname_start, char_u *resulting_dir);
180180
static void wipe_dummy_buffer(buf_T *buf, char_u *dirname_start);
181181
static void unload_dummy_buffer(buf_T *buf, char_u *dirname_start);
@@ -4189,7 +4189,7 @@ ex_copen(exarg_T *eap)
41894189
lnum = qfl->qf_index;
41904190

41914191
// Fill the buffer with the quickfix list.
4192-
qf_fill_buffer(qfl, curbuf, NULL);
4192+
qf_fill_buffer(qfl, curbuf, NULL, curwin->w_id);
41934193

41944194
decr_quickfix_busy();
41954195

@@ -4381,14 +4381,18 @@ qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
43814381
if (buf != NULL)
43824382
{
43834383
linenr_T old_line_count = buf->b_ml.ml_line_count;
4384+
int qf_winid = 0;
4385+
4386+
if (IS_LL_STACK(qi))
4387+
qf_winid = curwin->w_id;
43844388

43854389
if (old_last == NULL)
43864390
// set curwin/curbuf to buf and save a few things
43874391
aucmd_prepbuf(&aco, buf);
43884392

43894393
qf_update_win_titlevar(qi);
43904394

4391-
qf_fill_buffer(qf_get_curlist(qi), buf, old_last);
4395+
qf_fill_buffer(qf_get_curlist(qi), buf, old_last, qf_winid);
43924396
++CHANGEDTICK(buf);
43934397

43944398
if (old_last == NULL)
@@ -4415,7 +4419,8 @@ qf_buf_add_line(
44154419
buf_T *buf, // quickfix window buffer
44164420
linenr_T lnum,
44174421
qfline_T *qfp,
4418-
char_u *dirname)
4422+
char_u *dirname,
4423+
int qf_winid)
44194424
{
44204425
int len;
44214426
buf_T *errbuf;
@@ -4433,10 +4438,11 @@ qf_buf_add_line(
44334438
typval_T args[1];
44344439
dict_T *d;
44354440

4436-
// create 'info' dict argument
4441+
// create the dict argument
44374442
if ((d = dict_alloc_lock(VAR_FIXED)) == NULL)
44384443
return FAIL;
44394444
dict_add_number(d, "quickfix", (long)IS_QF_LIST(qfl));
4445+
dict_add_number(d, "winid", (long)qf_winid);
44404446
dict_add_number(d, "id", (long)qfl->qf_id);
44414447
dict_add_number(d, "idx", (long)(lnum + 1));
44424448
++d->dv_refcount;
@@ -4535,7 +4541,7 @@ qf_buf_add_line(
45354541
* ml_delete() is used and autocommands will be triggered.
45364542
*/
45374543
static void
4538-
qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last)
4544+
qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int qf_winid)
45394545
{
45404546
linenr_T lnum;
45414547
qfline_T *qfp;
@@ -4574,7 +4580,7 @@ qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last)
45744580
}
45754581
while (lnum < qfl->qf_count)
45764582
{
4577-
if (qf_buf_add_line(qfl, buf, lnum, qfp, dirname) == FAIL)
4583+
if (qf_buf_add_line(qfl, buf, lnum, qfp, dirname, qf_winid) == FAIL)
45784584
break;
45794585

45804586
++lnum;

src/testdir/test_quickfix.vim

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4822,7 +4822,7 @@ func Tqfexpr(info)
48224822
let qfl = getqflist({'id' : a:info.id, 'idx' : a:info.idx,
48234823
\ 'items' : 1}).items
48244824
else
4825-
let qfl = getloclist(0, {'id' : a:info.id, 'idx' : a:info.idx,
4825+
let qfl = getloclist(a:info.winid, {'id' : a:info.id, 'idx' : a:info.idx,
48264826
\ 'items' : 1}).items
48274827
endif
48284828

@@ -4863,7 +4863,7 @@ func Xtest_qftextfunc(cchar)
48634863
let qfl = getqflist({'id' : a:info.id, 'idx' : a:info.idx,
48644864
\ 'items' : 1}).items
48654865
else
4866-
let qfl = getloclist(0, {'id' : a:info.id, 'idx' : a:info.idx,
4866+
let qfl = getloclist(a:info.winid, {'id' : a:info.id, 'idx' : a:info.idx,
48674867
\ 'items' : 1}).items
48684868
endif
48694869
if empty(qfl)
@@ -4878,6 +4878,11 @@ func Xtest_qftextfunc(cchar)
48784878
call assert_equal('Line 10, Col 2', getline(1))
48794879
call assert_equal('Line 20, Col 4', getline(2))
48804880
Xclose
4881+
" Add entries to the list when the quickfix buffer is hidden
4882+
Xaddexpr ['F1:30:6:red']
4883+
Xwindow
4884+
call assert_equal('Line 30, Col 6', getline(3))
4885+
Xclose
48814886
call g:Xsetlist([], 'r', {'quickfixtextfunc' : ''})
48824887
set quickfixtextfunc&
48834888
delfunc PerQfText

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
933,
757759
/**/
758760
932,
759761
/**/

0 commit comments

Comments
 (0)