]> granicus.if.org Git - vim/commitdiff
patch 8.0.0580: cannot set the valid flag with setqflist() v8.0.0580
authorBram Moolenaar <Bram@vim.org>
Sat, 22 Apr 2017 19:20:46 +0000 (21:20 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 22 Apr 2017 19:20:46 +0000 (21:20 +0200)
Problem:    Cannot set the valid flag with setqflist().
Solution:   Add the "valid" argument. (Yegappan Lakshmanan, closes #1642)

runtime/doc/eval.txt
src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index 83bc8f379f9751ee115600ddc0ec0e9fc96932a3..20297f541b308577890eedff94d57c1d269ebf4a 100644 (file)
@@ -6945,6 +6945,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
@@ -6954,6 +6955,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
index b28a321f3cc8accf7f4345249053848e5e43c209..ea7f5809a9e099bc07031d5f77b9685b7845c587 100644 (file)
@@ -4779,6 +4779,10 @@ qf_add_entries(
            bufnum = 0;
        }
 
+       /* If the 'valid' field is present it overrules the detected value. */
+       if ((dict_find(d, (char_u *)"valid", -1)) != NULL)
+           valid = (int)get_dict_number(d, (char_u *)"valid");
+
        status =  qf_add_entry(qi,
                               NULL,        /* dir */
                               filename,
index c77f3c94c07aeb66150853f387087e9a53bf85cd..fa14190f3babbebbcd6d16bb586e190d838449d4 100644 (file)
@@ -1201,6 +1201,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}," .
index f7d0a785aebaeeb220d74a7b286f311928ed6e49..c41cc5abba6f2980a4adf94991927fa71133690b 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    580,
 /**/
     579,
 /**/