Problem with feedkeys() in Test_window_cmd_cmdwin_with_vsp()

29 views
Skip to first unread message

Yegappan Lakshmanan

unread,
Dec 3, 2019, 1:16:40 PM12/3/19
to vim_dev
Hi all,

While debugging a failure in Appveyor with PR 5307, I found
the following. The existing test Test_window_cmd_cmdwin_with_vsp()
is interfering with the new Test_yank_block() test. I can reproduce
the problem using the following simple function:

func Test_window_cmd_cmdwin_with_vsp()
call feedkeys("q:\<CR>")
new | only!
call feedkeys('', 'x')
endfunc

If I invoke the above function in MS-Windows GUI Vim, I see the
following error:

:<t_ýT>
Error detected while processing function Test_window_cmd_cmdwin_with_vsp:
line 3:
E488: Trailing characters

I couldn't figure out why the special character is getting inserted
into the command line. Any suggestions?

I have worked around this by changing Test_yank_block() to
use normal instead of feedkeys().

Thanks,
Yegappan

Yegappan Lakshmanan

unread,
Dec 3, 2019, 1:29:32 PM12/3/19
to vim_dev
Hi,

On Tue, Dec 3, 2019 at 10:16 AM Yegappan Lakshmanan <yega...@gmail.com> wrote:
>
> Hi all,
>
> While debugging a failure in Appveyor with PR 5307, I found
> the following. The existing test Test_window_cmd_cmdwin_with_vsp()
> is interfering with the new Test_yank_block() test. I can reproduce
> the problem using the following simple function:
>
> func Test_window_cmd_cmdwin_with_vsp()
> call feedkeys("q:\<CR>")
> new | only!
> call feedkeys('', 'x')
> endfunc
>
> If I invoke the above function in MS-Windows GUI Vim, I see the
> following error:
>
> :<t_ýT>
> Error detected while processing function Test_window_cmd_cmdwin_with_vsp:
> line 3:
> E488: Trailing characters
>
> I couldn't figure out why the special character is getting inserted
> into the command line. Any suggestions?
>

I have minimized the steps that triggers this issue to:

:call feedkeys(":q\<CR>", "x")

Just executing the above command triggers the error.

- Yegappan

Bram Moolenaar

unread,
Dec 4, 2019, 9:11:54 AM12/4/19
to vim...@googlegroups.com, Yegappan Lakshmanan

Yegappan wrote:

> On Tue, Dec 3, 2019 at 10:16 AM Yegappan Lakshmanan <yega...@gmail.com> wrote:
> >
> > Hi all,
> >
> > While debugging a failure in Appveyor with PR 5307, I found
> > the following. The existing test Test_window_cmd_cmdwin_with_vsp()
> > is interfering with the new Test_yank_block() test. I can reproduce
> > the problem using the following simple function:
> >
> > func Test_window_cmd_cmdwin_with_vsp()
> > call feedkeys("q:\<CR>")
> > new | only!
> > call feedkeys('', 'x')
> > endfunc
> >
> > If I invoke the above function in MS-Windows GUI Vim, I see the
> > following error:
> >
> > :<t_ýT>
> > Error detected while processing function Test_window_cmd_cmdwin_with_vsp:
> > line 3:
> > E488: Trailing characters
> >
> > I couldn't figure out why the special character is getting inserted
> > into the command line. Any suggestions?
> >
>
> I have minimized the steps that triggers this issue to:
>
> :call feedkeys(":q\<CR>", "x")
>
> Just executing the above command triggers the error.

I think you mean ":q\<CR>".

The "q:" sequence is translated to ":" and K_CMDWIN. in
getcmdline_int() there is this code:

if (c == cedit_key || c == K_CMDWIN)
{
if (ex_normal_busy == 0 && got_int == FALSE)
{
/*
* Open a window to edit the command line (and history).
*/
c = open_cmdwin();
some_key_typed = TRUE;
}
}

Since ex_normal_busy is set it won't open the cmdline window, but insert
the key in the command line. The following CR then executes it.

Now I wonder why ex_normal_busy is checked here. Inserting K_CMDWIN
doesn't make sense. We can at least make it:

if ((c == K_CMDWIN || ex_normal_busy == 0) && got_int == FALSE)

Just staying on the safe side, perhaps checking ex_normal_busy can be
removed, but I don't recall why it was added.

--
hundred-and-one symptoms of being an internet addict:
179. You wonder why your household garbage can doesn't have an
"empty recycle bin" button.

/// 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,
Dec 4, 2019, 10:27:56 AM12/4/19
to vim...@googlegroups.com
According to git blame, this comes from patch 7.4.441
https://github.com/vim/vim/commit/58da707d2412f60eb5c0e158ade48dd8a13c96ed

Problem: Endless loop and other problems when 'cedit' is set to CTRL-C.
Solution: Do not call ex_window() when ex_normal_busy or got_int was set.
(Yasuhiro Matsumoto)

Best,
Christian
--
"Ich kann das Predigen nicht vertragen; ich glaube, ich habe in
meiner Jugend mich daran übergessen."
-- Goethe, Maximen und Reflektionen, Nr. 202

Yegappan Lakshmanan

unread,
Dec 4, 2019, 10:55:44 AM12/4/19
to Bram Moolenaar, vim_dev
Hi Bram,
Yes. I meant to type "q:" to open the cmd window.

>
> The "q:" sequence is translated to ":" and K_CMDWIN. in
> getcmdline_int() there is this code:
>
> if (c == cedit_key || c == K_CMDWIN)
> {
> if (ex_normal_busy == 0 && got_int == FALSE)
> {
> /*
> * Open a window to edit the command line (and history).
> */
> c = open_cmdwin();
> some_key_typed = TRUE;
> }
> }
>
> Since ex_normal_busy is set it won't open the cmdline window, but insert
> the key in the command line. The following CR then executes it.
>

It looks like the feedkeys("q:", "xt") call doesn't open the cmd window.
How does one open the cmd window from a script then?

>
> Now I wonder why ex_normal_busy is checked here. Inserting K_CMDWIN
> doesn't make sense. We can at least make it:
>
> if ((c == K_CMDWIN || ex_normal_busy == 0) && got_int == FALSE)
>
> Just staying on the safe side, perhaps checking ex_normal_busy can be
> removed, but I don't recall why it was added.
>

Based on Christian's reply, it looks like this change might reintroduce the
bug fixed by 7.4.441.

Regards,
Yegappan

Yegappan Lakshmanan

unread,
Dec 4, 2019, 11:06:40 AM12/4/19
to vim_dev
Hi,
I am not able to reproduce the problems reported by Yasuhiro Matsumoto
using Vim 8.1.2385.

The e-mail thread for 7.4.441 is below:

>
> * CASE1:
>
> Note: vim will hang. And it require kill -9.
>
> :set cedit=<c-c>
> :normal! :
>
> => endless loop
>
> * CASE2:
>
> :set cedit=<C-c>
> :echo input('')
>
> Type <c-c>
>
> => broken cmdwin are displayed
>

Even though these problems are not seen now, it will be good to add tests
for these.

- Yegappan

Bram Moolenaar

unread,
Dec 4, 2019, 1:09:38 PM12/4/19
to vim...@googlegroups.com, Yegappan Lakshmanan
I think my careful change is correct. Also removing the check for cedit
would re-introduce the problem.

> The e-mail thread for 7.4.441 is below:
>
> >
> > * CASE1:
> >
> > Note: vim will hang. And it require kill -9.
> >
> > :set cedit=<c-c>
> > :normal! :
> >
> > => endless loop
> >
> > * CASE2:
> >
> > :set cedit=<C-c>
> > :echo input('')
> >
> > Type <c-c>
> >
> > => broken cmdwin are displayed
> >
>
> Even though these problems are not seen now, it will be good to add tests
> for these.

Always good to test what was fixed!

--
hundred-and-one symptoms of being an internet addict:
182. You may not know what is happening in the world, but you know
every bit of net-gossip there is.
Reply all
Reply to author
Forward
0 new messages