I wrote:

> > In xterm, the terminal option `'t_RV'` needs to be cleared to reproduce the 
> > issue.  Run this shell command
> > 
> >     vim -Nu NONE -S <(cat <<'EOF'
> >         set t_RV=
> >         call writefile([], '/tmp/somefile')
> >         autocmd QuickFixCmdPost * !less /tmp/somefile
> >         doautocmd QuickFixCmdPost
> >     EOF
> >     )
> > 
> > Then, press `q` to close `less(1)`, then press `<Left>`; `E349` is 
> > unexpectedly raised:
> > 
> >     E349: No identifier under cursor
> 
> Thanks for the info.  I can also reproduce it without the autocommand,
> just typing ":!less /tmp/somefile" does the same.
> 
> What happens is that Vim receives ESC [ D  for the Left cursor key.
> This is not recognized, the Left key is expected to produce ESC O D.
> The Esc key is then used to leave the Enter prompt and the remaining [ D
> is a command to search for the identifier under the cursor.
> 
> At the Enter prompt the terminal hasn't been switched back to termcap
> mode yet, because that might switch to the alternate screen and you
> can't see the shell command output.  Making the Left key produce a
> different Escape sequence is a side effect.
> 
> This could perhaps be fixed by going to half-termcap mode, only
> outputting some of the codes and sending t_ti later.  However, the
> effect is unpredictable, the termcap codes may contain anything.
> 
> Another way would be to also recognize the alternate form of the Left
> key.  But we would need to do the same for many special keys.
> 
> Since it's been like this for ages without complaints, and trying to fix
> this will most likely have side effects, I think we should just leave
> it.

Actually, we do have a set of termcap entries for the other form of the
cursor keys, but they start with Esc [ 1.  I'm not sure why the
requirement for that number one comes from, perhaps it works if we leave
it out:


--- ../prev/term.c      2020-12-18 19:49:52.389571687 +0100
+++ term.c      2020-12-29 14:50:48.493170891 +0100
@@ -914,10 +914,10 @@
     {K_RIGHT,          IF_EB("\033O*C", ESC_STR "O*C")},
     {K_LEFT,           IF_EB("\033O*D", ESC_STR "O*D")},
     // An extra set of cursor keys for vt100 mode
-    {K_XUP,            IF_EB("\033[1;*A", ESC_STR "[1;*A")},
-    {K_XDOWN,          IF_EB("\033[1;*B", ESC_STR "[1;*B")},
-    {K_XRIGHT,         IF_EB("\033[1;*C", ESC_STR "[1;*C")},
-    {K_XLEFT,          IF_EB("\033[1;*D", ESC_STR "[1;*D")},
+    {K_XUP,            IF_EB("\033[;*A", ESC_STR "[;*A")},
+    {K_XDOWN,          IF_EB("\033[;*B", ESC_STR "[;*B")},
+    {K_XRIGHT,         IF_EB("\033[;*C", ESC_STR "[;*C")},
+    {K_XLEFT,          IF_EB("\033[;*D", ESC_STR "[;*D")},
     // An extra set of function keys for vt100 mode
     {K_XF1,            IF_EB("\033O*P", ESC_STR "O*P")},
     {K_XF2,            IF_EB("\033O*Q", ESC_STR "O*Q")},

-- 
It was recently discovered that research causes cancer in rats.

 /// 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202012291403.0BTE3dk8638835%40masaka.moolenaar.net.

Raspunde prin e-mail lui