vim-patch:8.0.0580: cannot set the valid flag with setqflist()

Problem:    Cannot set the valid flag with setqflist().
Solution:   Add the "valid" argument. (Yegappan Lakshmanan, closes vim/vim#1642)

f1d21c8cc8
This commit is contained in:
James McCoy 2017-12-18 21:40:34 -05:00
parent 9fb7926a0d
commit 4d2d844c12
No known key found for this signature in database
GPG Key ID: DFE691AE331BA3DB
3 changed files with 27 additions and 0 deletions

View File

@ -6841,6 +6841,7 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()*
nr error number
text description of the error
type single-character error type, 'E', 'W', etc.
valid recognized error message
The "col", "vcol", "nr", "type" and "text" entries are
optional. Either "lnum" or "pattern" entry can be used to
@ -6850,6 +6851,8 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()*
item will not be handled as an error line.
If both "pattern" and "lnum" are present then "pattern" will
be used.
If the "valid" entry is not supplied, then the valid flag is
set when "bufnr" is a valid buffer or "filename" exists.
If you supply an empty {list}, the quickfix list will be
cleared.
Note that the list is not exactly the same as what

View File

@ -4189,6 +4189,11 @@ static int qf_add_entries(qf_info_T *qi, list_T *list, char_u *title,
bufnum = 0;
}
// If the 'valid' field is present it overrules the detected value.
if (tv_dict_find(d, "valid", -1) != NULL) {
valid = (int)tv_dict_get_number(d, "valid");
}
int status = qf_add_entry(qi,
NULL, // dir
(char_u *)filename,

View File

@ -1183,6 +1183,25 @@ func SetXlistTests(cchar, bnum)
let l = g:Xgetlist()
call assert_equal(0, len(l))
" Tests for setting the 'valid' flag
call g:Xsetlist([{'bufnr':a:bnum, 'lnum':4, 'valid':0}])
Xwindow
call assert_equal(1, winnr('$'))
let l = g:Xgetlist()
call g:Xsetlist(l)
call assert_equal(0, g:Xgetlist()[0].valid)
call g:Xsetlist([{'text':'Text1', 'valid':1}])
Xwindow
call assert_equal(2, winnr('$'))
Xclose
let save_efm = &efm
set efm=%m
Xgetexpr 'TestMessage'
let l = g:Xgetlist()
call g:Xsetlist(l)
call assert_equal(1, g:Xgetlist()[0].valid)
let &efm = save_efm
" Error cases:
" Refer to a non-existing buffer and pass a non-dictionary type
call assert_fails("call g:Xsetlist([{'bufnr':998, 'lnum':4}," .