mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.0.0517: there is no way to remove quickfix lists
Problem: There is no way to remove quickfix lists (for testing). Solution: Add the 'f' action to setqflist(). Add tests. (Yegappan Lakshmanan)
This commit is contained in:
@@ -6936,16 +6936,19 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()*
|
|||||||
Note that the list is not exactly the same as what
|
Note that the list is not exactly the same as what
|
||||||
|getqflist()| returns.
|
|getqflist()| returns.
|
||||||
|
|
||||||
*E927*
|
{action} values: *E927*
|
||||||
If {action} is set to 'a', then the items from {list} are
|
'a' The items from {list} are added to the existing
|
||||||
added to the existing quickfix list. If there is no existing
|
quickfix list. If there is no existing list, then a
|
||||||
list, then a new list is created.
|
new list is created.
|
||||||
|
|
||||||
If {action} is set to 'r', then the items from the current
|
'r' The items from the current quickfix list are replaced
|
||||||
quickfix list are replaced with the items from {list}. This
|
with the items from {list}. This can also be used to
|
||||||
can also be used to clear the list: >
|
clear the list: >
|
||||||
:call setqflist([], 'r')
|
:call setqflist([], 'r')
|
||||||
<
|
<
|
||||||
|
'f' All the quickfix lists in the quickfix stack are
|
||||||
|
freed.
|
||||||
|
|
||||||
If {action} is not present or is set to ' ', then a new list
|
If {action} is not present or is set to ' ', then a new list
|
||||||
is created.
|
is created.
|
||||||
|
|
||||||
|
@@ -10038,7 +10038,8 @@ set_qf_ll_list(
|
|||||||
act = get_tv_string_chk(action_arg);
|
act = get_tv_string_chk(action_arg);
|
||||||
if (act == NULL)
|
if (act == NULL)
|
||||||
return; /* type error; errmsg already given */
|
return; /* type error; errmsg already given */
|
||||||
if ((*act == 'a' || *act == 'r' || *act == ' ') && act[1] == NUL)
|
if ((*act == 'a' || *act == 'r' || *act == ' ' || *act == 'f') &&
|
||||||
|
act[1] == NUL)
|
||||||
action = *act;
|
action = *act;
|
||||||
else
|
else
|
||||||
EMSG2(_(e_invact), act);
|
EMSG2(_(e_invact), act);
|
||||||
|
@@ -717,7 +717,8 @@ qf_get_next_file_line(qfstate_T *state)
|
|||||||
|
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
/* Convert a line if it contains a non-ASCII character. */
|
/* Convert a line if it contains a non-ASCII character. */
|
||||||
if (state->vc.vc_type != CONV_NONE && has_non_ascii(state->linebuf)) {
|
if (state->vc.vc_type != CONV_NONE && has_non_ascii(state->linebuf))
|
||||||
|
{
|
||||||
char_u *line;
|
char_u *line;
|
||||||
|
|
||||||
line = string_convert(&state->vc, state->linebuf, &state->linelen);
|
line = string_convert(&state->vc, state->linebuf, &state->linelen);
|
||||||
@@ -917,7 +918,8 @@ restofline:
|
|||||||
}
|
}
|
||||||
if (fmt_ptr->flags == '+' && !qi->qf_multiscan) /* %+ */
|
if (fmt_ptr->flags == '+' && !qi->qf_multiscan) /* %+ */
|
||||||
{
|
{
|
||||||
if (linelen > fields->errmsglen) {
|
if (linelen > fields->errmsglen)
|
||||||
|
{
|
||||||
/* linelen + null terminator */
|
/* linelen + null terminator */
|
||||||
if ((fields->errmsg = vim_realloc(fields->errmsg,
|
if ((fields->errmsg = vim_realloc(fields->errmsg,
|
||||||
linelen + 1)) == NULL)
|
linelen + 1)) == NULL)
|
||||||
@@ -931,7 +933,8 @@ restofline:
|
|||||||
if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
|
if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
|
||||||
continue;
|
continue;
|
||||||
len = (int)(regmatch.endp[i] - regmatch.startp[i]);
|
len = (int)(regmatch.endp[i] - regmatch.startp[i]);
|
||||||
if (len > fields->errmsglen) {
|
if (len > fields->errmsglen)
|
||||||
|
{
|
||||||
/* len + null terminator */
|
/* len + null terminator */
|
||||||
if ((fields->errmsg = vim_realloc(fields->errmsg, len + 1))
|
if ((fields->errmsg = vim_realloc(fields->errmsg, len + 1))
|
||||||
== NULL)
|
== NULL)
|
||||||
@@ -1013,7 +1016,8 @@ restofline:
|
|||||||
fields->namebuf[0] = NUL; /* no match found, remove file name */
|
fields->namebuf[0] = NUL; /* no match found, remove file name */
|
||||||
fields->lnum = 0; /* don't jump to this line */
|
fields->lnum = 0; /* don't jump to this line */
|
||||||
fields->valid = FALSE;
|
fields->valid = FALSE;
|
||||||
if (linelen > fields->errmsglen) {
|
if (linelen > fields->errmsglen)
|
||||||
|
{
|
||||||
/* linelen + null terminator */
|
/* linelen + null terminator */
|
||||||
if ((fields->errmsg = vim_realloc(fields->errmsg,
|
if ((fields->errmsg = vim_realloc(fields->errmsg,
|
||||||
linelen + 1)) == NULL)
|
linelen + 1)) == NULL)
|
||||||
@@ -4798,7 +4802,8 @@ qf_add_entries(
|
|||||||
qi->qf_lists[qi->qf_curlist].qf_nonevalid = TRUE;
|
qi->qf_lists[qi->qf_curlist].qf_nonevalid = TRUE;
|
||||||
else
|
else
|
||||||
qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
|
qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
|
||||||
if (action != 'a') {
|
if (action != 'a')
|
||||||
|
{
|
||||||
qi->qf_lists[qi->qf_curlist].qf_ptr =
|
qi->qf_lists[qi->qf_curlist].qf_ptr =
|
||||||
qi->qf_lists[qi->qf_curlist].qf_start;
|
qi->qf_lists[qi->qf_curlist].qf_start;
|
||||||
if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
|
if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
|
||||||
@@ -4861,6 +4866,18 @@ qf_set_properties(qf_info_T *qi, dict_T *what, int action)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
qf_free_stack(win_T *wp, qf_info_T *qi)
|
||||||
|
{
|
||||||
|
qf_free_all(wp);
|
||||||
|
if (wp == NULL)
|
||||||
|
{
|
||||||
|
/* quickfix list */
|
||||||
|
qi->qf_curlist = 0;
|
||||||
|
qi->qf_listcount = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Populate the quickfix list with the items supplied in the list
|
* Populate the quickfix list with the items supplied in the list
|
||||||
* of dictionaries. "title" will be copied to w:quickfix_title.
|
* of dictionaries. "title" will be copied to w:quickfix_title.
|
||||||
@@ -4884,7 +4901,12 @@ set_errorlist(
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (what != NULL)
|
if (action == 'f')
|
||||||
|
{
|
||||||
|
/* Free the entire quickfix or location list stack */
|
||||||
|
qf_free_stack(wp, qi);
|
||||||
|
}
|
||||||
|
else if (what != NULL)
|
||||||
retval = qf_set_properties(qi, what, action);
|
retval = qf_set_properties(qi, what, action);
|
||||||
else
|
else
|
||||||
retval = qf_add_entries(qi, list, title, action);
|
retval = qf_add_entries(qi, list, title, action);
|
||||||
@@ -5187,7 +5209,8 @@ ex_helpgrep(exarg_T *eap)
|
|||||||
/* Convert a line if 'encoding' is not utf-8 and
|
/* Convert a line if 'encoding' is not utf-8 and
|
||||||
* the line contains a non-ASCII character. */
|
* the line contains a non-ASCII character. */
|
||||||
if (vc.vc_type != CONV_NONE
|
if (vc.vc_type != CONV_NONE
|
||||||
&& has_non_ascii(IObuff)) {
|
&& has_non_ascii(IObuff))
|
||||||
|
{
|
||||||
line = string_convert(&vc, IObuff, NULL);
|
line = string_convert(&vc, IObuff, NULL);
|
||||||
if (line == NULL)
|
if (line == NULL)
|
||||||
line = IObuff;
|
line = IObuff;
|
||||||
|
@@ -38,6 +38,7 @@ func s:setup_commands(cchar)
|
|||||||
command! -nargs=* Xhelpgrep helpgrep <args>
|
command! -nargs=* Xhelpgrep helpgrep <args>
|
||||||
let g:Xgetlist = function('getqflist')
|
let g:Xgetlist = function('getqflist')
|
||||||
let g:Xsetlist = function('setqflist')
|
let g:Xsetlist = function('setqflist')
|
||||||
|
call setqflist([], 'f')
|
||||||
else
|
else
|
||||||
command! -nargs=* -bang Xlist <mods>llist<bang> <args>
|
command! -nargs=* -bang Xlist <mods>llist<bang> <args>
|
||||||
command! -nargs=* Xgetexpr <mods>lgetexpr <args>
|
command! -nargs=* Xgetexpr <mods>lgetexpr <args>
|
||||||
@@ -69,6 +70,7 @@ func s:setup_commands(cchar)
|
|||||||
command! -nargs=* Xhelpgrep lhelpgrep <args>
|
command! -nargs=* Xhelpgrep lhelpgrep <args>
|
||||||
let g:Xgetlist = function('getloclist', [0])
|
let g:Xgetlist = function('getloclist', [0])
|
||||||
let g:Xsetlist = function('setloclist', [0])
|
let g:Xsetlist = function('setloclist', [0])
|
||||||
|
call setloclist(0, [], 'f')
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -76,6 +78,9 @@ endfunc
|
|||||||
func XlistTests(cchar)
|
func XlistTests(cchar)
|
||||||
call s:setup_commands(a:cchar)
|
call s:setup_commands(a:cchar)
|
||||||
|
|
||||||
|
if a:cchar == 'l'
|
||||||
|
call assert_fails('llist', 'E776:')
|
||||||
|
endif
|
||||||
" With an empty list, command should return error
|
" With an empty list, command should return error
|
||||||
Xgetexpr []
|
Xgetexpr []
|
||||||
silent! Xlist
|
silent! Xlist
|
||||||
@@ -146,6 +151,9 @@ endfunc
|
|||||||
func XageTests(cchar)
|
func XageTests(cchar)
|
||||||
call s:setup_commands(a:cchar)
|
call s:setup_commands(a:cchar)
|
||||||
|
|
||||||
|
let list = [{'bufnr': 1, 'lnum': 1}]
|
||||||
|
call g:Xsetlist(list)
|
||||||
|
|
||||||
" Jumping to a non existent list should return error
|
" Jumping to a non existent list should return error
|
||||||
silent! Xolder 99
|
silent! Xolder 99
|
||||||
call assert_true(v:errmsg ==# 'E380: At bottom of quickfix stack')
|
call assert_true(v:errmsg ==# 'E380: At bottom of quickfix stack')
|
||||||
@@ -179,11 +187,7 @@ func XageTests(cchar)
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_cage()
|
func Test_cage()
|
||||||
let list = [{'bufnr': 1, 'lnum': 1}]
|
|
||||||
call setqflist(list)
|
|
||||||
call XageTests('c')
|
call XageTests('c')
|
||||||
|
|
||||||
call setloclist(0, list)
|
|
||||||
call XageTests('l')
|
call XageTests('l')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -192,6 +196,11 @@ endfunc
|
|||||||
func XwindowTests(cchar)
|
func XwindowTests(cchar)
|
||||||
call s:setup_commands(a:cchar)
|
call s:setup_commands(a:cchar)
|
||||||
|
|
||||||
|
" Opening the location list window without any errors should fail
|
||||||
|
if a:cchar == 'l'
|
||||||
|
call assert_fails('lopen', 'E776:')
|
||||||
|
endif
|
||||||
|
|
||||||
" Create a list with no valid entries
|
" Create a list with no valid entries
|
||||||
Xgetexpr ['non-error 1', 'non-error 2', 'non-error 3']
|
Xgetexpr ['non-error 1', 'non-error 2', 'non-error 3']
|
||||||
|
|
||||||
@@ -232,6 +241,19 @@ func XwindowTests(cchar)
|
|||||||
" Calling cwindow should close the quickfix window with no valid errors
|
" Calling cwindow should close the quickfix window with no valid errors
|
||||||
Xwindow
|
Xwindow
|
||||||
call assert_true(winnr('$') == 1)
|
call assert_true(winnr('$') == 1)
|
||||||
|
|
||||||
|
if a:cchar == 'c'
|
||||||
|
" Opening the quickfix window in multiple tab pages should reuse the
|
||||||
|
" quickfix buffer
|
||||||
|
Xgetexpr ['Xtestfile1:1:3:Line1', 'Xtestfile2:2:2:Line2',
|
||||||
|
\ 'Xtestfile3:3:1:Line3']
|
||||||
|
Xopen
|
||||||
|
let qfbufnum = bufnr('%')
|
||||||
|
tabnew
|
||||||
|
Xopen
|
||||||
|
call assert_equal(qfbufnum, bufnr('%'))
|
||||||
|
new | only | tabonly
|
||||||
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_cwindow()
|
func Test_cwindow()
|
||||||
@@ -360,6 +382,13 @@ endfunc
|
|||||||
func Xtest_browse(cchar)
|
func Xtest_browse(cchar)
|
||||||
call s:setup_commands(a:cchar)
|
call s:setup_commands(a:cchar)
|
||||||
|
|
||||||
|
" Jumping to first or next location list entry without any error should
|
||||||
|
" result in failure
|
||||||
|
if a:cchar == 'l'
|
||||||
|
call assert_fails('lfirst', 'E776:')
|
||||||
|
call assert_fails('lnext', 'E776:')
|
||||||
|
endif
|
||||||
|
|
||||||
call s:create_test_file('Xqftestfile1')
|
call s:create_test_file('Xqftestfile1')
|
||||||
call s:create_test_file('Xqftestfile2')
|
call s:create_test_file('Xqftestfile2')
|
||||||
|
|
||||||
@@ -1550,6 +1579,11 @@ endfunc
|
|||||||
func XbottomTests(cchar)
|
func XbottomTests(cchar)
|
||||||
call s:setup_commands(a:cchar)
|
call s:setup_commands(a:cchar)
|
||||||
|
|
||||||
|
" Calling lbottom without any errors should fail
|
||||||
|
if a:cchar == 'l'
|
||||||
|
call assert_fails('lbottom', 'E776:')
|
||||||
|
endif
|
||||||
|
|
||||||
call g:Xsetlist([{'filename': 'foo', 'lnum': 42}])
|
call g:Xsetlist([{'filename': 'foo', 'lnum': 42}])
|
||||||
Xopen
|
Xopen
|
||||||
let wid = win_getid()
|
let wid = win_getid()
|
||||||
@@ -1571,10 +1605,9 @@ endfunc
|
|||||||
func HistoryTest(cchar)
|
func HistoryTest(cchar)
|
||||||
call s:setup_commands(a:cchar)
|
call s:setup_commands(a:cchar)
|
||||||
|
|
||||||
call assert_fails(a:cchar . 'older 99', 'E380:')
|
|
||||||
" clear all lists after the first one, then replace the first one.
|
" clear all lists after the first one, then replace the first one.
|
||||||
call g:Xsetlist([])
|
call g:Xsetlist([])
|
||||||
Xolder
|
call assert_fails('Xolder 99', 'E380:')
|
||||||
let entry = {'filename': 'foo', 'lnum': 42}
|
let entry = {'filename': 'foo', 'lnum': 42}
|
||||||
call g:Xsetlist([entry], 'r')
|
call g:Xsetlist([entry], 'r')
|
||||||
call g:Xsetlist([entry, entry])
|
call g:Xsetlist([entry, entry])
|
||||||
@@ -1617,6 +1650,7 @@ func Xproperty_tests(cchar)
|
|||||||
call assert_fails('call g:Xsetlist([], "a", [])', 'E715:')
|
call assert_fails('call g:Xsetlist([], "a", [])', 'E715:')
|
||||||
|
|
||||||
" Set and get the title
|
" Set and get the title
|
||||||
|
call g:Xsetlist([])
|
||||||
Xopen
|
Xopen
|
||||||
wincmd p
|
wincmd p
|
||||||
call g:Xsetlist([{'filename':'foo', 'lnum':27}])
|
call g:Xsetlist([{'filename':'foo', 'lnum':27}])
|
||||||
|
@@ -764,6 +764,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
517,
|
||||||
/**/
|
/**/
|
||||||
516,
|
516,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user