return qi->qf_lists[qf_idx].qf_count <= 0;
}
-
/*
* Allocate the fields used for parsing lines and populating a quickfix list.
*/
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;
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);
}
// 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);
- }
}
/*
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);
- }
}
}
}
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"));
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')