Ingo Karkat wrote:
> Hello Vim developers,
>
> The :cwindow command is supposed to close the quickfix window when "there are
> no
> recognized errors". I think I found two bugs (in Vim 7.3.146 on Linux/x86, but
> reproducible even in Vim 7.0 and on MS Windows).
>
>
> First:
>
> vim -N -u NONE
> :call setqflist([])
> :cwindow
> " quickfix window doesn't open, as expected
> :call setqflist([], 'r')
> :cwindow
> " empty quickfix window opens: unexpected!
> :echo getqflist()
> []
>
> I'm totally new to the quickfix implementation, but I was able to fix this by
> checking qf_count instead of qf_index (which seems to contain a previous value
> in the "replace" case of setqflist()). Hopefully someone with more insights
> into
> the different members of the struct can confirm this.
>
> diff -r 24b41d74f6a9 src/quickfix.c
> --- a/src/quickfix.c Sun Mar 27 16:03:15 2011 +0200
> +++ b/src/quickfix.c Fri Apr 15 15:03:52 2011 +0200
> @@ -3699,7 +3699,7 @@
> }
> }
>
> - if (qi->qf_lists[qi->qf_curlist].qf_index == 0)
> + if (qi->qf_lists[qi->qf_curlist].qf_count == 0)
> /* empty list or no valid entry */
> qi->qf_lists[qi->qf_curlist].qf_nonevalid = TRUE;
> else
>
>
> Second: A :vimgrep that yields no matches causes :cwindow to open an empty
> quickfix window, whereas :make and :grep correctly make :cwindow close / keep
> the window closed.
>
> vim -N -u NONE
> :vimgrep doesnotexist /etc/passwd
> " On Windows, use :vimgrep doesnotexist NUL
> E480: No match: doesnotexist
> :cwindow
> " empty quickfix window opens: unexpected!
> :echo getqflist()
> []
>
> I found two approaches to fix that: Either by explicitly making :cwindow check
> for an empty number of items:
>
> diff -r 24b41d74f6a9 src/quickfix.c
> --- a/src/quickfix.c Sun Mar 27 16:03:15 2011 +0200
> +++ b/src/quickfix.c Fri Apr 15 14:43:18 2011 +0200
> @@ -2243,6 +2243,7 @@
> * it if we have errors; otherwise, leave it closed.
> */
> if (qi->qf_lists[qi->qf_curlist].qf_nonevalid
> + || qi->qf_lists[qi->qf_curlist].qf_count == 0
> || qi->qf_curlist >= qi->qf_listcount)
> {
> if (win != NULL)
>
> But, as this doesn't seem to be necessary for all the other commands that fill
> the quickfix list, I think it's more appropriate to make :vimgrep set the
> qf_nonevalid flag when there were no matches:
>
> diff -r 24b41d74f6a9 src/quickfix.c
> --- a/src/quickfix.c Sun Mar 27 16:03:15 2011 +0200
> +++ b/src/quickfix.c Fri Apr 15 15:03:52 2011 +0200
> @@ -3312,7 +3312,7 @@
>
> FreeWild(fcount, fnames);
>
> - qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
> + qi->qf_lists[qi->qf_curlist].qf_nonevalid =
> ((qi->qf_lists[qi->qf_curlist].qf_count > 0) ? FALSE : TRUE);
> qi->qf_lists[qi->qf_curlist].qf_ptr =
> qi->qf_lists[qi->qf_curlist].qf_start;
> qi->qf_lists[qi->qf_curlist].qf_index = 1;
>
> Again, I hope for the insights of developers more familiar with the code.
Thanks. I'll look into this later.
--
hundred-and-one symptoms of being an internet addict:
9. All your daydreaming is preoccupied with getting a faster connection to the
net: 28.8...ISDN...cable modem...T1...T3.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
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