Skip to content

Commit f1d21c8

Browse files
committed
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 #1642)
1 parent 9b77016 commit f1d21c8

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

runtime/doc/eval.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6945,6 +6945,7 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()*
69456945
nr error number
69466946
text description of the error
69476947
type single-character error type, 'E', 'W', etc.
6948+
valid recognized error message
69486949

69496950
The "col", "vcol", "nr", "type" and "text" entries are
69506951
optional. Either "lnum" or "pattern" entry can be used to
@@ -6954,6 +6955,8 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()*
69546955
item will not be handled as an error line.
69556956
If both "pattern" and "lnum" are present then "pattern" will
69566957
be used.
6958+
If the "valid" entry is not supplied, then the valid flag is
6959+
set when "bufnr" is a valid buffer or "filename" exists.
69576960
If you supply an empty {list}, the quickfix list will be
69586961
cleared.
69596962
Note that the list is not exactly the same as what

src/quickfix.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4779,6 +4779,10 @@ qf_add_entries(
47794779
bufnum = 0;
47804780
}
47814781

4782+
/* If the 'valid' field is present it overrules the detected value. */
4783+
if ((dict_find(d, (char_u *)"valid", -1)) != NULL)
4784+
valid = (int)get_dict_number(d, (char_u *)"valid");
4785+
47824786
status = qf_add_entry(qi,
47834787
NULL, /* dir */
47844788
filename,

src/testdir/test_quickfix.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,25 @@ func SetXlistTests(cchar, bnum)
12011201
let l = g:Xgetlist()
12021202
call assert_equal(0, len(l))
12031203

1204+
" Tests for setting the 'valid' flag
1205+
call g:Xsetlist([{'bufnr':a:bnum, 'lnum':4, 'valid':0}])
1206+
Xwindow
1207+
call assert_equal(1, winnr('$'))
1208+
let l = g:Xgetlist()
1209+
call g:Xsetlist(l)
1210+
call assert_equal(0, g:Xgetlist()[0].valid)
1211+
call g:Xsetlist([{'text':'Text1', 'valid':1}])
1212+
Xwindow
1213+
call assert_equal(2, winnr('$'))
1214+
Xclose
1215+
let save_efm = &efm
1216+
set efm=%m
1217+
Xgetexpr 'TestMessage'
1218+
let l = g:Xgetlist()
1219+
call g:Xsetlist(l)
1220+
call assert_equal(1, g:Xgetlist()[0].valid)
1221+
let &efm = save_efm
1222+
12041223
" Error cases:
12051224
" Refer to a non-existing buffer and pass a non-dictionary type
12061225
call assert_fails("call g:Xsetlist([{'bufnr':998, 'lnum':4}," .

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
580,
767769
/**/
768770
579,
769771
/**/

0 commit comments

Comments
 (0)