Hi,
Since the skip_vimgrep_pat null terminates the given string after the
pattern the quickfix title ends up being truncated. The following
command ':vimgrep /foo/j *.c/' would set the 'w:quickfix_title' variable
to ':vimgrep /foo' instead of ':vimgrep /foo/j *.c'. The solution is to
copy the command line prior calling skip_vimgrep_pat and use it as the
quickfix title. The patch also includes a test case.

-- 
:wq

-- 
-- 
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 eb6433e..2709145 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -3286,6 +3286,7 @@ ex_vimgrep(exarg_T *eap)
     int                fcount;
     char_u     **fnames;
     char_u     *fname;
+    char_u     *title;
     char_u     *s;
     char_u     *p;
     int                fi;
@@ -3354,6 +3355,7 @@ ex_vimgrep(exarg_T *eap)
 
     /* Get the search pattern: either white-separated or enclosed in // */
     regmatch.regprog = NULL;
+    title = vim_strsave(*eap->cmdlinep);
     p = skip_vimgrep_pat(eap->arg, &s, &flags);
     if (p == NULL)
     {
@@ -3390,7 +3392,7 @@ ex_vimgrep(exarg_T *eap)
         eap->cmdidx != CMD_vimgrepadd && eap->cmdidx != CMD_lvimgrepadd)
                                        || qi->qf_curlist == qi->qf_listcount)
        /* make place for a new list */
-       qf_new_list(qi, *eap->cmdlinep);
+       qf_new_list(qi, title != NULL ? title : *eap->cmdlinep);
     else if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
        /* Adding to existing list, find last entry. */
        for (prevp = qi->qf_lists[qi->qf_curlist].qf_start;
@@ -3669,6 +3671,8 @@ ex_vimgrep(exarg_T *eap)
     }
 
 theend:
+    if (title != NULL)
+       vim_free(title);
     vim_free(dirname_now);
     vim_free(dirname_start);
     vim_free(target_dir);
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 4be37d5..af601c7 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -317,6 +317,23 @@ func Test_errortitle()
   augroup! QfBufWinEnter
 endfunc
 
+func Test_vimgreptitle()
+  augroup QfBufWinEnter
+    au!
+    au BufWinEnter * :let g:a=get(w:, 'quickfix_title', 'NONE')
+  augroup END
+  try
+    vimgrep /pattern/j file
+  catch /E480/
+  endtry
+  copen
+  call assert_equal(':    vimgrep /pattern/j file', g:a)
+  augroup QfBufWinEnter
+    au!
+  augroup END
+  augroup! QfBufWinEnter
+endfunc
+
 function XqfTitleTests(cchar)
   let Xgetexpr = a:cchar . 'getexpr'
   if a:cchar == 'c'

Raspunde prin e-mail lui