]> granicus.if.org Git - vim/commitdiff
patch 8.2.0933: 'quickfixtextfunc' does not get window ID of location list v8.2.0933
authorBram Moolenaar <Bram@vim.org>
Mon, 8 Jun 2020 17:20:27 +0000 (19:20 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 8 Jun 2020 17:20:27 +0000 (19:20 +0200)
Problem:    'quickfixtextfunc' does not get window ID of location list.
Solution:   Add "winid" to the dict argument. (Yegappan Lakshmanan,
            closes #6222)

runtime/doc/quickfix.txt
src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index 4f3112c2340e0bee752787cd678f808529dea43a..982044c5bf074cd0cd561774ad30253c56da1bfe 100644 (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
 
index b4ecaad32edd94ac5815ca3d30a3cbf22227c195..0da8ea27f1c27908106e5a43fffc955d6d668dd3 100644 (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;
index 96729a4e93d37a4ca14028b52795523b853ba182..7587d979e588682e5c48980e76305b47dedc9ec0 100644 (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
index 420d655a72a1f8187787f4ce83a5ba25f18eb66e..54369e4a73c393b680bdf49a5ce72df95bb8c5f0 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    933,
 /**/
     932,
 /**/