vim-patch:8.1.0259: no test for fixed quickfix issue

Problem:    No test for fixed quickfix issue.
Solution:   Add a test.  Clean up the code a bit. (Yegappan Lakshmanan)
3f347e4716
This commit is contained in:
Jan Edmund Lazo 2019-09-13 00:38:42 -04:00
parent 4ef9ad0514
commit fba9c72495
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
2 changed files with 36 additions and 3 deletions

View File

@ -728,6 +728,15 @@ static int qf_get_nextline(qfstate_T *state)
return QF_OK;
}
// Returns true if the specified quickfix/location list is empty.
static bool qf_list_empty(const qf_info_T *qi, int qf_idx)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
if (qi == NULL || qf_idx < 0 || qf_idx >= LISTCOUNT) {
return true;
}
return qi->qf_lists[qf_idx].qf_count <= 0;
}
/// Parse a line and get the quickfix fields.
/// Return the QF_ status.
@ -2906,8 +2915,7 @@ void qf_view_result(bool 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;
}
@ -3456,7 +3464,8 @@ static void qf_jump_first(qf_info_T *qi, unsigned 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);
}
}

View File

@ -3515,6 +3515,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')