]> granicus.if.org Git - vim/commitdiff
patch 8.1.0259: no test for fixed quickfix issue v8.1.0259
authorBram Moolenaar <Bram@vim.org>
Thu, 9 Aug 2018 19:19:20 +0000 (21:19 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 9 Aug 2018 19:19:20 +0000 (21:19 +0200)
Problem:    No test for fixed quickfix issue.
Solution:   Add a test.  Clean up the code a bit. (Yegappan Lakshmanan)

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

index d4aa5090da38cfc7c05169a0cf371f77f8ec393f..14fcfcff4363cb0c37eb4856d902af2025b1f64e 100644 (file)
@@ -1506,7 +1506,6 @@ qf_list_empty(qf_info_T *qi, int qf_idx)
     return qi->qf_lists[qf_idx].qf_count <= 0;
 }
 
-
 /*
  * Allocate the fields used for parsing lines and populating a quickfix list.
  */
@@ -3717,7 +3716,7 @@ qf_view_result(int split)
     if (IS_LL_WINDOW(curwin))
        qi = GET_LOC_LIST(curwin);
 
-    if (qi == NULL || qi->qf_lists[qi->qf_curlist].qf_count == 0)
+    if (qf_list_empty(qi, qi->qf_curlist))
     {
        EMSG(_(e_quickfix));
        return;
@@ -4349,7 +4348,8 @@ qf_jump_first(qf_info_T *qi, int_u save_qfid, int forceit)
     if (qi->qf_lists[qi->qf_curlist].qf_id != save_qfid)
        qi->qf_curlist = qf_id2nr(qi, save_qfid);
 
-    if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
+    // Autocommands might have cleared the list, check for it
+    if (!qf_list_empty(qi, qi->qf_curlist))
        qf_jump(qi, 0, 0, forceit);
 }
 
@@ -4873,10 +4873,8 @@ ex_cfile(exarg_T *eap)
     // free the list.
     if (res > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile)
            && qflist_valid(wp, save_qfid))
-    {
        // display the first error
        qf_jump_first(qi, save_qfid, eap->forceit);
-    }
 }
 
 /*
@@ -6581,10 +6579,8 @@ ex_cbuffer(exarg_T *eap)
            if (res > 0 && (eap->cmdidx == CMD_cbuffer ||
                                                eap->cmdidx == CMD_lbuffer)
                    && qflist_valid(wp, save_qfid))
-           {
                // display the first error
                qf_jump_first(qi, save_qfid, eap->forceit);
-           }
        }
     }
 }
@@ -6661,10 +6657,8 @@ ex_cexpr(exarg_T *eap)
            if (res > 0 && (eap->cmdidx == CMD_cexpr
                                                   || eap->cmdidx == CMD_lexpr)
                    && qflist_valid(wp, save_qfid))
-           {
                // display the first error
                qf_jump_first(qi, save_qfid, eap->forceit);
-           }
        }
        else
            EMSG(_("E777: String or List expected"));
index d41815f3ce8b0204e8d563c2ba20a935f192fea6..ce19e74d3f0cceb33b57d0f6c7b4ac1f50a4dc97 100644 (file)
@@ -3478,6 +3478,30 @@ func Xautocmd_changelist(cchar)
   call assert_equal(5, line('.'))
   autocmd! QuickFixCmdPost
 
+  " Test for autocommands clearing the quickfix list before jumping to the
+  " first error. This should not result in an error
+  autocmd QuickFixCmdPost * call g:Xsetlist([], 'r')
+  let v:errmsg = ''
+  " Test for cfile/lfile
+  Xfile Xerr
+  call assert_true(v:errmsg !~# 'E42:')
+  " Test for cbuffer/lbuffer
+  edit Xerr
+  Xbuffer
+  call assert_true(v:errmsg !~# 'E42:')
+  " Test for cexpr/lexpr
+  Xexpr 'Xtestfile2:4:Line4'
+  call assert_true(v:errmsg !~# 'E42:')
+  " Test for grep/lgrep
+  " The grepprg may not be set on non-Unix systems
+  if has('unix')
+    silent Xgrep Line5 Xtestfile2
+    call assert_true(v:errmsg !~# 'E42:')
+  endif
+  " Test for vimgrep/lvimgrep
+  call assert_fails('silent Xvimgrep Line5 Xtestfile2', 'E480:')
+  autocmd! QuickFixCmdPost
+
   call delete('Xerr')
   call delete('Xtestfile1')
   call delete('Xtestfile2')
index 4f31d66e8758d72784fc8c1673e1c765e17786b3..dadb978b31024cfe20413d721019b9358bf1d0e6 100644 (file)
@@ -794,6 +794,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    259,
 /**/
     258,
 /**/