Hi Bram and developers!

2016-9-4(Sun) 22:40:41 UTC+9 h_east:
> Hi Bram and developers,
> 
> 2016-9-3(Sat) 21:52:42 UTC+9 Bram Moolenaar:
> > Hirohito Higashi wrote:
> > 
> > > How to reproduce:
> > > - Prepare the following vim script file.
> > >   $ cat sample1.vim
> > > function! Sample()
> > >     return 'autocmd '
> > > endfunction
> > > call feedkeys("i\<c-r>=Sample()\<CR>\<C-x>\<C-v>")
> > > 
> > > - Run vanilla vim with execute above file.
> > >   $ vim -Nu NONE -S sample1.vim
> > > 
> > > 
> > > Expected behavior (I think):
> > > Current line displayed `autocomd BufAdd` and popup menu is appeared.
> > > 
> > > 
> > > Actual behavior:
> > > completion is not performed.
> > > Below message diplayed in last line.
> > > "-- Command-line completion (^V^N^P) Pattern not found"
> > > 
> > > 
> > > Is this bug?
> > > I don't know. But I wrote a patch with a test.
> > > Please check an attached patch.
> > 
> > Isn't the problem that the completion is using ccline, but when getting
> > there from insert mode it's never set?  So ccline.cmdfirstc is "="
> > because of the previous command.
> 
> Okay. I would try to more investigate.
> Thanks.

I had more investigate and update a patch.
Perhaps, you will accept an attached patch :-)
--
Best regards,
Hirohito Higashi (a.k.a. h_east)

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/ex_getln.c b/src/ex_getln.c
index ed82f0f..5f1e386 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -218,6 +218,7 @@ getcmdline(
      * custom status line may invoke ":normal". */
     struct cmdline_info save_ccline;
 #endif
+    int		cmdfirstc_save;
 
 #ifdef FEAT_EVAL
     if (firstc == -1)
@@ -249,13 +250,19 @@ getcmdline(
     /*
      * set some variables for redrawcmd()
      */
+    if (firstc == '=')
+	cmdfirstc_save = ccline.cmdfirstc;
     ccline.cmdfirstc = (firstc == '@' ? 0 : firstc);
     ccline.cmdindent = (firstc > 0 ? indent : 0);
 
     /* alloc initial ccline.cmdbuff */
     alloc_cmdbuff(exmode_active ? 250 : indent + 1);
     if (ccline.cmdbuff == NULL)
+    {
+	if (firstc == '=')
+	    ccline.cmdfirstc = cmdfirstc_save;
 	return NULL;			    /* out of memory */
+    }
     ccline.cmdlen = ccline.cmdpos = 0;
     ccline.cmdbuff[0] = NUL;
 
@@ -2085,6 +2092,8 @@ returncmd:
 
 	/* Make ccline empty, getcmdline() may try to use it. */
 	ccline.cmdbuff = NULL;
+	if (firstc == '=')
+	    ccline.cmdfirstc = cmdfirstc_save;
 	return p;
     }
 }
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index c029ca1..264cad8 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -220,6 +220,7 @@ func Test_augroup_warning()
   augroup Another
   augroup END
   call assert_true(match(execute('au VimEnter'), "-Deleted-.*VimEnter") >= 0)
+  augroup! Another
 
   " no warning for postpone aucmd delete
   augroup StartOK
diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim
index dd94933..6e07393 100644
--- a/src/testdir/test_popup.vim
+++ b/src/testdir/test_popup.vim
@@ -242,22 +242,27 @@ func! Test_popup_completion_insertmode()
   iunmap <F5>
 endfunc
 
-function! ComplTest() abort
-  call complete(1, ['source', 'soundfold'])
-  return ''
-endfunction
-
 func Test_noinsert_complete()
+  function! s:complTest1() abort
+    call complete(1, ['source', 'soundfold'])
+    return ''
+  endfunction
+
+  function! s:complTest2() abort
+    call complete(1, ['source', 'soundfold'])
+    return ''
+  endfunction
+
   new
   set completeopt+=noinsert
-  inoremap <F5>  <C-R>=ComplTest()<CR>
+  inoremap <F5>  <C-R>=s:complTest1()<CR>
   call feedkeys("i\<F5>soun\<CR>\<CR>\<ESC>.", 'tx')
   call assert_equal('soundfold', getline(1))
   call assert_equal('soundfold', getline(2))
   bwipe!
 
   new
-  inoremap <F5>  <C-R>=Test()<CR>
+  inoremap <F5>  <C-R>=s:complTest2()<CR>
   call feedkeys("i\<F5>\<CR>\<ESC>", 'tx')
   call assert_equal('source', getline(1))
   bwipe!
@@ -266,10 +271,20 @@ func Test_noinsert_complete()
   iunmap <F5>
 endfunc
 
+func Test_compl_vim_cmds_after_register_expr()
+  function! s:test_func()
+    return 'autocmd '
+  endfunction
+  augroup AAAAA_Group
+    au!
+  augroup END
 
-function! Test() abort
-  call complete(1, ['source', 'soundfold'])
-  return ''
-endfunction
+  new
+  call feedkeys("i\<c-r>=s:test_func()\<CR>\<C-x>\<C-v>\<Esc>", 'tx')
+  call assert_equal('autocmd AAAAA_Group', getline(1))
+  autocmd! AAAAA_Group
+  augroup! AAAAA_Group
+  bwipe!
+endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab

Raspunde prin e-mail lui