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 vim/vim#6222)
7ba5a7eff3
This commit is contained in:
kevinhwang91 2021-05-04 13:55:38 +08:00
parent ebe1a08366
commit 00246d7be5
3 changed files with 23 additions and 8 deletions

View File

@ -1915,6 +1915,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

@ -3728,7 +3728,7 @@ void 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->handle);
decr_quickfix_busy();
@ -3891,6 +3891,11 @@ static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
buf = qf_find_buf(qi);
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->handle;
}
if (old_last == NULL) {
// set curwin/curbuf to buf and save a few things
@ -3899,7 +3904,7 @@ static void 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);
buf_inc_changedtick(buf);
if (old_last == NULL) {
@ -3920,7 +3925,7 @@ static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
// Add an error line to the quickfix buffer.
static int qf_buf_add_line(qf_list_T *qfl, buf_T *buf, linenr_T lnum,
const qfline_T *qfp,
char_u *dirname, bool first_bufline)
char_u *dirname, int qf_winid, bool first_bufline)
FUNC_ATTR_NONNULL_ALL
{
int len;
@ -3938,10 +3943,11 @@ static int qf_buf_add_line(qf_list_T *qfl, buf_T *buf, linenr_T lnum,
char_u *qfbuf_text;
typval_T args[1];
// create 'info' dict argument
// create the dict argument
dict_T *const dict = tv_dict_alloc_lock(VAR_FIXED);
tv_dict_add_nr(dict, S_LEN("quickfix"), IS_QF_LIST(qfl));
tv_dict_add_nr(dict, S_LEN("winid"), qf_winid);
tv_dict_add_nr(dict, S_LEN("id"), qfl->qf_id);
tv_dict_add_nr(dict, S_LEN("idx"), lnum + 1);
dict->dv_refcount++;
@ -4028,7 +4034,8 @@ static int qf_buf_add_line(qf_list_T *qfl, buf_T *buf, linenr_T lnum,
/// If "old_last" is not NULL append the items after this one.
/// When "old_last" is NULL then "buf" must equal "curbuf"! Because 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)
static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last,
int qf_winid)
FUNC_ATTR_NONNULL_ARG(2)
{
linenr_T lnum;
@ -4067,7 +4074,7 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last)
lnum = buf->b_ml.ml_line_count;
}
while (lnum < qfl->qf_count) {
if (qf_buf_add_line(qfl, buf, lnum, qfp, dirname,
if (qf_buf_add_line(qfl, buf, lnum, qfp, dirname, qf_winid,
prev_bufnr != qfp->qf_fnum) == FAIL) {
break;
}

View File

@ -4812,7 +4812,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
@ -4853,7 +4853,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)
@ -4868,6 +4868,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