Ctrl_L behave like Ctrl_P while pum_visible.

530 views
Skip to first unread message

mattn

unread,
Jan 5, 2015, 5:24:47 AM1/5/15
to vim...@googlegroups.com

bug.vim
-------------------
set nocompatible

inoremap <F5> <C-R>=ListMonths()<CR>

func! ListMonths()
call complete(col('.'), ['January', 'February', 'March',
\ 'April', 'May', 'June', 'July', 'August', 'September',
\ 'October', 'November', 'December'])
return ''
endfunc
-------------------

1. vim -u bug.vim -N

2. press F5

3. type Ctrl-L while popup menu is visible

Ctrl-L should not behave like Ctrl-P. ins_compl_key2dir() handles suffix keys after CTRL-X. And also it handles keys while popup menu is visible (ex: CTRL-P/CTRL-N). This should be cleanly separated.

https://gist.github.com/mattn/2c83d5a17c9e9505e43d

- Yasuhiro Matsumoto

Yasuhiro MATSUMOTO

unread,
Jan 5, 2015, 8:06:09 AM1/5/15
to vim...@googlegroups.com
Sorry it's an expected
> --
> --
> 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+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


--
- Yasuhiro Matsumoto

Amadeus Demarzi

unread,
Jan 5, 2015, 1:38:43 PM1/5/15
to vim...@googlegroups.com
+1 on getting this fixed. This bug has been pretty annoying as of late.

Cheers

Amadeus Demarzi

unread,
Jan 5, 2015, 2:02:52 PM1/5/15
to vim...@googlegroups.com
I just tested this patch, and it doesn't quite work the way it had originally (before this bug).

I have the following map in my .vimrc:

inoremap <c-l> <esc>A

I often use that to jump to the end of a line while in insert mode. However, this patch just means that nothing happens when I press <c-l>, whereas before the cursor would jump to the end of the line. Now I have to first close the pop up, and then I can use <c-l>.

So it's good in the sense that it fixes the previous issue where <c-l> would cycle through the popup options, however now it just prevents anything from happening.

Hope this all made sense.

Bram Moolenaar

unread,
Jan 5, 2015, 2:58:27 PM1/5/15
to mattn, vim...@googlegroups.com
Thanks!

--
hundred-and-one symptoms of being an internet addict:
42. Your virtual girlfriend finds a new net sweetheart with a larger bandwidth.

/// Bram Moolenaar -- Br...@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 ///

Christian Brabandt

unread,
Jan 6, 2015, 5:39:56 AM1/6/15
to vim...@googlegroups.com
Am 2015-01-05 20:02, schrieb Amadeus Demarzi:
> I just tested this patch, and it doesn't quite work the way it had
> originally (before this bug).
>
> I have the following map in my .vimrc:
>
> inoremap <c-l> <esc>A
>
> I often use that to jump to the end of a line while in insert mode.
> However, this patch just means that nothing happens when I press
> <c-l>, whereas before the cursor would jump to the end of the line.
> Now I have to first close the pop up, and then I can use <c-l>.
>
> So it's good in the sense that it fixes the previous issue where <c-l>
> would cycle through the popup options, however now it just prevents
> anything from happening.

I am not sure I understand. Remapped insertmode completion keys won't
work when
the popup menu is shown. That means, your imaped <c-l> didn't work in an
unpatched vim when the popup menu was displayed.
At least, that is what I am seeing here.

(Internally, Vim uses the complete-line mode for the complete() function
and that's why the <c-l> did select the previous item. I think, one
should
use a special state for the complete() function instead of (re-)using
the
line completion mode. Then <C-L> should just work)

Best,
Christian

Amadeus Demarzi

unread,
Jan 6, 2015, 1:17:39 PM1/6/15
to vim...@googlegroups.com
Perhaps in the past I was just exploiting a bug. But I have had the <c-l> mapping for a long time, and I use the NeoComplete plugin for my autocompletion. <c-l> has worked great for a long time with the popup window visible, but recently it stopped working. It may be using a custom complete function as you say, and that functionality would have to be fixed in NeoComplete.

Christian Brabandt

unread,
Jan 6, 2015, 1:25:43 PM1/6/15
to vim...@googlegroups.com
Hi vim_dev!
Here is a patch, that does that and fixes the CTRL-L behaviour. Also the
inoremap <c-l> case should work when used in a popupmenu started by the
completion() function.

Best,
Christian
--
Was ist Ketzerei?
Die Meinung aller, die nicht so denken wie wir.
-- Friedrich II. der Große
complete_ctrl_L.diff

Amadeus Demarzi

unread,
Jan 6, 2015, 2:01:34 PM1/6/15
to vim...@googlegroups.com
You are a god amongst men Christian, works like a charm, thanks!

h_east

unread,
Jan 6, 2015, 2:09:31 PM1/6/15
to vim...@googlegroups.com
Hi Christian,

2015/1/7(Wed) 3:25:43 UTC+9 Christian Brabandt:
Nice. Perhaps I think that We need a little more modification such an attached a patch url.
https://gist.github.com/h-east/be555467ddfc3dfb8d54

Best regards,
Hirohito Higashi (a.k.a h_east)

h_east

unread,
Jan 6, 2015, 9:15:50 PM1/6/15
to vim...@googlegroups.com
Hi list,

2015/1/7(Wed) 4:09:31 UTC+9 h_east:
> Nice. Perhaps I think that We need a little more modification such an attached a patch url.
> https://gist.github.com/h-east/be555467ddfc3dfb8d54

I updated Gist. (Add line#19)

Amadeus Demarzi

unread,
Jan 15, 2015, 8:49:54 PM1/15/15
to vim...@googlegroups.com
Any movement on this? Would love to see at the very least, Christian's patch merged in soon if possible.

Cheers,
Amadeus

Shougo

unread,
Jan 19, 2015, 8:16:06 AM1/19/15
to vim...@googlegroups.com
2015年1月16日金曜日 10時49分54秒 UTC+9 Amadeus Demarzi:
Hi, I tested both Christian and h_east patches.

1. Christian patch

It seems simple. But it has bugs.
If you press <C-h> key in complete() completion window, it displays "ins_complete()" error.
And it disables completion select keys(<C-n>, <C-p>, <Down>, <Up>) and narrowing candidates features.

2. h_east patch

It is long and complex. But it is backward compatible.
Unfortunatelly, complete() feature has other several bugs.
h_east patch only fixes for the Ctrl-L problem.

I think h_east patch is better.

Christian Brabandt

unread,
Jan 19, 2015, 10:32:27 AM1/19/15
to vim...@googlegroups.com
Hi Shougo!

On Mo, 19 Jan 2015, Shougo wrote:

> 2. h_east patch
>
> It is long and complex. But it is backward compatible.
> Unfortunatelly, complete() feature has other several bugs.
> h_east patch only fixes for the Ctrl-L problem.
>
> I think h_east patch is better.

Yes I think this patch is better. What other problems have you observed?


Best,
Christian
--
Bringen Hufeisen wirklich Glück? Ich bezweifle es - ich habe schon
viele unglückliche Pferde gesehen.
-- Pearl Sydenstricker Buck (Pseudonym: Sedges, John)

Shougo

unread,
Jan 19, 2015, 5:34:56 PM1/19/15
to vim...@googlegroups.com
2015年1月20日火曜日 0時32分27秒 UTC+9 Christian Brabandt:
OK.

1. complete() does not break lines by text width option.
2. If you press <C-h> key in complete() completion window, Vim will execute whole line completion.
3. If you use complete(), Vim breaks dot register(undo buffer).

Some problems are already created patch.
I or other people will report or send patch for the problems later.

h_east

unread,
Jan 19, 2015, 8:04:17 PM1/19/15
to vim...@googlegroups.com
Hi Shougo and Christian,

2015/1/20(Tue) 7:34:56 UTC+9 Shougo:
P.S.
I'm working in progress.
I investigated at last weekend and I will investigate at this weekend.
See below. (in Japanese)
https://github.com/vim-jp/issues/issues/682 (Closed)
https://github.com/vim-jp/issues/issues/685 (Open)
https://github.com/vim-jp/issues/issues/683 (Open)

Of course, it is welcome that you write a patch ;-)

h_east

unread,
Feb 8, 2015, 12:21:55 PM2/8/15
to vim...@googlegroups.com, matt...@gmail.com
Hi Bram and Nice Vim developers,

2015/1/6(Tue) 4:58:27 UTC+9 Bram Moolenaar:
> Yasuhiro Matsumoto wrote:
>
> > bug.vim
> > -------------------
> > set nocompatible
> >
> > inoremap <F5> <C-R>=ListMonths()<CR>
> >
> > func! ListMonths()
> > call complete(col('.'), ['January', 'February', 'March',
> > \ 'April', 'May', 'June', 'July', 'August', 'September',
> > \ 'October', 'November', 'December'])
> > return ''
> > endfunc
> > -------------------
> >
> > 1. vim -u bug.vim -N
> >
> > 2. press F5
> >
> > 3. type Ctrl-L while popup menu is visible
> >
> > Ctrl-L should not behave like Ctrl-P. ins_compl_key2dir() handles
> > suffix keys after CTRL-X. And also it handles keys while popup menu is
> > visible (ex: CTRL-P/CTRL-N). This should be cleanly separated.
> >
> > https://gist.github.com/mattn/2c83d5a17c9e9505e43d
>
> Thanks!

I update a patch. (Attached to this email)
Please check.

And ...
I found specification inconsistency between 'complete()' and 'backspace' option.

How to reproduce:
1. cat test.vim
inoremap <F5> <C-R>=ListMonths()<CR>

func! ListMonths()
call complete(1, ['One', 'Three'])
return ''
endfunc

2. vim -N -u test.vim

3. Enter insert-mode and input 'ab' and leave insert-mode.
iab<Esc>

4. Reenter insert-mode and use 'complete()'
a<F5>

5. Delete two characters.
<C-H><C-H>

What happen.
- '4.' Edit start columns 3, but 'complete()' starts 1 (by 1st argument).
- '5.' Can't delete column 1 and 2
'backspace' option not contain "start", So vim can not deleted this.

I think this is specification inconsistency.
How Let's fix?
(a) Occurred an error when 'comple()' first argument is can not be deleted by under the influence of the 'backspace' option.

(b) Adjust the first argument value implicitly in f_complete(). (In this case, Ajust 3)

(c) Between 'comple ()' is functioning to ignore the 'backspace' option.

I would write the patch when you are determined.
builtin_func_complete_fix.patch

Pedro Ferrari

unread,
Feb 16, 2015, 5:11:19 PM2/16/15
to vim...@googlegroups.com, matt...@gmail.com
+1

h_east

unread,
Feb 17, 2015, 10:43:35 AM2/17/15
to vim...@googlegroups.com, matt...@gmail.com
Hi Bram,

2015/2/9(Mon) 2:21:55 UTC+9 h_east:
> Hi Bram and Nice Vim developers,
>
> 2015/1/6(Tue) 4:58:27 UTC+9 Bram Moolenaar:
> > Yasuhiro Matsumoto wrote:
> >
> > > bug.vim
> > > -------------------
> > > set nocompatible
> > >
> > > inoremap <F5> <C-R>=ListMonths()<CR>
> > >
> > > func! ListMonths()
> > > call complete(col('.'), ['January', 'February', 'March',
> > > \ 'April', 'May', 'June', 'July', 'August', 'September',
> > > \ 'October', 'November', 'December'])
> > > return ''
> > > endfunc
> > > -------------------
> > >
> > > 1. vim -u bug.vim -N
> > >
> > > 2. press F5
> > >
> > > 3. type Ctrl-L while popup menu is visible
> > >
> > > Ctrl-L should not behave like Ctrl-P. ins_compl_key2dir() handles
> > > suffix keys after CTRL-X. And also it handles keys while popup menu is
> > > visible (ex: CTRL-P/CTRL-N). This should be cleanly separated.
> > >
> > > https://gist.github.com/mattn/2c83d5a17c9e9505e43d
> >
> > Thanks!
>
> I update a patch. (Attached to this email)
> Please check.

Oops. My previous patch had a problem. so I attached a new patch.
Please check.

>
> And ...
> I found specification inconsistency between 'complete()' and 'backspace' option.
>
> How to reproduce:
> 1. cat test.vim
> inoremap <F5> <C-R>=ListMonths()<CR>
>
> func! ListMonths()
> call complete(1, ['One', 'Three'])
> return ''
> endfunc
>
> 2. vim -N -u test.vim
>
> 3. Enter insert-mode and input 'ab' and leave insert-mode.
> iab<Esc>
>
> 4. Reenter insert-mode and use 'complete()'
> a<F5>
>
> 5. Delete two characters.
> <C-H><C-H>
>
> What happen.
> - '4.' Edit start columns 3, but 'complete()' starts 1 (by 1st argument).
> - '5.' Can't delete column 1 and 2
> 'backspace' option not contain "start", So vim can not deleted this.
>
> I think this is specification inconsistency.
> How Let's fix?
> (a) Occurred an error when 'complete()' first argument is can not be deleted by under the influence of the 'backspace' option.
>
> (b) Adjust the first argument value implicitly in f_complete(). (In this case, Ajust 3)
>
> (c) Between 'complete()' is functioning to ignore the 'backspace' option.
>
> I would write the patch when you are determined.

Bram, Please decide a specification.
builtin_func_complete_fix2.patch

Bram Moolenaar

unread,
Feb 17, 2015, 11:26:32 AM2/17/15
to h_east, vim...@googlegroups.com, matt...@gmail.com
Thanks for the update.
The 'backspace' option should probably be ignored in this situation,
since the code says to change those characters. 'backspace' is really
to make Vim backwards compatible with Vi, for those users who prefer it
that way. I don't think it should apply to Insert mode completion.

--
hundred-and-one symptoms of being an internet addict:
243. You unsuccessfully try to download a pizza from www.dominos.com.

h_east

unread,
Feb 18, 2015, 3:30:31 AM2/18/15
to vim...@googlegroups.com, h.eas...@gmail.com, matt...@gmail.com
Hi Bram,

2015/2/18(Wed) 1:26:32 UTC+9 Bram Moolenaar:
Thanks for the reply.
I was convinced to your opinion. But thinking has changed to one that is by analyzing the source code in order to write a patch.
Because, The completion mode has been finished(*1) before function ins_bs() is called When I first press the <C-H> key at reproduce step '5.'.

*1: ins_compl_active() returns 0 and ctrl_x_mode is 0.

Therefore, it is impossible to determination of whether a complementing in ins_bs().

So, the specification I'd be in (a) or (b).
What do you think?

h_east

unread,
Feb 18, 2015, 4:11:27 AM2/18/15
to vim...@googlegroups.com, h.eas...@gmail.com, matt...@gmail.com
Hi Bram and list,

2015/2/18(Wed) 17:30:31 UTC+9 h_east:
Postscript:
My analysis results and opinion for the Vim that apply my patch (builtin_func_complete_fix2.patch).

Bram Moolenaar

unread,
Feb 18, 2015, 5:09:40 PM2/18/15
to h_east, vim...@googlegroups.com, matt...@gmail.com

Hirohito Higashi wrote:

[...]
If I remember correctly, ins_bs() is used also for inserting the
completed string to make redo work properly. It should be possible to
make ins_bs() behave like 'backspace' is set. Either by passing an
argument or temporarily setting the option.

Or perhaps change the Insert start position to the column in complete().
Not sure if that causes problems (there have been some bugs related to
changing the insert start position).

--
hundred-and-one symptoms of being an internet addict:
248. You sign your letters with your e-mail address instead of your name.

h_east

unread,
Feb 19, 2015, 10:13:20 AM2/19/15
to vim...@googlegroups.com, h.eas...@gmail.com, matt...@gmail.com
Hi Bram,

2015/2/19(Thu) 7:09:40 UTC+9 Bram Moolenaar:
I have tried to actually implement the plan (b).
There was a problem as it was said of you. Indeed You're Vim BOSS yeah!

And I don't understand how to implement plan (c) that by using redo work.
May I ask your implementation of plan (c)?

My patch(builtin_func_complete_fix2.patch) may fixed other 'complete()' bugs.
First, I want include this patch.

Thank you.
Reply all
Reply to author
Forward
0 new messages