Re: [bug?][patch] Vim command completion is not performed, when expression register inserted

2016-09-05 Fir de Conversatie Bram Moolenaar

Hirohito Higashi wrote:

> 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\=Sample()\\\")
> > > > 
> > > > - 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 :-)

Hmm, this still has some unexpected dependency.  How about this: when
set_cmd_context() is called from ins_complete() pass a flag that means
"do not using ccline".  Then in set_cmd_context() skip the part that uses
ccline.  Oh well, I suppose I might as well do that then.  And use your
test, that's the bulk of the work.


-- 
Did you ever see a "Hit any key to continue" message in a music piece?

 /// Bram Moolenaar -- b...@moolenaar.net -- 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

--- 
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.


Re: [bug?][patch] Vim command completion is not performed, when expression register inserted

2016-09-05 Fir de Conversatie h_east
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\=Sample()\\\")
> > > 
> > > - 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 
 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   =ComplTest()
+  inoremap   =s:complTest1()
   call feedkeys("i\soun\\\.", 'tx')
   call assert_equal('soundfold', getline(1))
   call assert_equal('soundfold', getline(2))
   bwipe!
 
   new
-  inoremap   =Test()
+  inoremap   =s:complTest2()
   call feedkeys("i\\\", 'tx')
   call assert_equal('source', getline(1))
   bwipe!
@@ -266,10 +271,20 @@ func Test_noinsert_complete()
   iunmap 
 endfunc
 
+func Test_compl_vim_cmds_after_register_expr()
+  function! s:test_func()
+return 'autocmd '
+  endfunction
+  augroup A_Group
+au!
+  augroup END
 
-function! Test() abort
-  call complete(1, ['source', 'soundfold'])
-  return ''
-endfunction
+  new
+  call feedkeys("i\=s:test_func()", 'tx')
+  call assert_equal('autocmd A_Group', getline(1))
+  autocmd! A_Group
+  augroup! A_Group
+  bwipe!
+endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab


Re: [bug?][patch] Vim command completion is not performed, when expression register inserted

2016-09-04 Fir de Conversatie 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\=Sample()\\\")
> > 
> > - 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.
--
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.


Re: [bug?][patch] Vim command completion is not performed, when expression register inserted

2016-09-03 Fir de Conversatie 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\=Sample()\\\")
> 
> - 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.


-- 
Drink wet cement and get really stoned.

 /// Bram Moolenaar -- b...@moolenaar.net -- 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

--- 
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.