Hi,
On Wed, Apr 19, 2017 at 4:23 PM, Daniel Hahler
<[email protected]> wrote:
> It might also be possible to allow for setting valid?!
>
> Are you referring to changing the setqflist() function to accept the valid
> flag field and not checking for a valid file name and a line number?
>
> Yes.
> This way you could set this flag yourself in general, but it would fix the
> issue at hand (since valid is contained already, and would be used as-is
> when passing it to setqflist()).
>
The attached patch implements the support for setting the 'valid' flag
using the setqflist() function and tests for this functionality.
- Yegappan
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/quickfix.c b/src/quickfix.c
index b28a321f3..93c7984bd 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -4779,6 +4779,10 @@ qf_add_entries(
bufnum = 0;
}
+ /* If the 'valid' field is passed in, then use it.*/
+ 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,
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index b5d0c1b85..716f07d9e 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -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}," .