]> granicus.if.org Git - vim/commitdiff
patch 8.2.1982: quickfix window now updated when adding invalid entries v8.2.1982
authorBram Moolenaar <Bram@vim.org>
Sat, 14 Nov 2020 12:15:24 +0000 (13:15 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 14 Nov 2020 12:15:24 +0000 (13:15 +0100)
Problem:    Quickfix window now updated when adding invalid entries.
Solution:   Update the quickfix buffer properly. (Yegappan Lakshmanan, closes
            #7291, closes #7271)

src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index ac95ace493c10241964e4ddd2092a41afabc49a6..40897b6b6005c1a7f641c557cf7c556126fa6719 100644 (file)
@@ -4674,14 +4674,17 @@ qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int qf_winid)
        *dirname = NUL;
 
        // Add one line for each error
-       if (old_last == NULL || old_last->qf_next == NULL)
+       if (old_last == NULL)
        {
            qfp = qfl->qf_start;
            lnum = 0;
        }
        else
        {
-           qfp = old_last->qf_next;
+           if (old_last->qf_next != NULL)
+               qfp = old_last->qf_next;
+           else
+               qfp = old_last;
            lnum = buf->b_ml.ml_line_count;
        }
 
index 196aa1d8d5e78d640a23da3c71ab36ec29df4a33..395ecc6e1cbdddd0d6e46c7b09f968ab97ab23be 100644 (file)
@@ -5145,4 +5145,17 @@ func Test_setloclist_crash()
   %bw!
 endfunc
 
+" Test for adding an invalid entry with the quickfix window open and making
+" sure that the window contents are not changed
+func Test_add_invalid_entry_with_qf_window()
+  call setqflist([], 'f')
+  cexpr "Xfile1:10:aa"
+  copen
+  call setqflist(['bb'], 'a')
+  call assert_equal(1, line('$'))
+  call assert_equal(['Xfile1|10| aa'], getline(1, '$'))
+  call assert_equal([{'lnum': 10, 'bufnr': bufnr('Xfile1'), 'col': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': 'aa'}], getqflist())
+  cclose
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 3dde5b22a8a8c928f550d159af2f0bb618636ddf..db4d84793ee5ce9c31611591ef8817362e790c11 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1982,
 /**/
     1981,
 /**/