patch 9.0.0980: the keyboard state response may end up in a shell command
Problem: The keyboard state response may end up in a shell command.
Solution: Only request the keyboard protocol state when the typeahead is
empty, no more commands are following and not exiting. Add the
t_RK termcap entry for this.
diff --git a/runtime/doc/term.txt b/runtime/doc/term.txt
index 2bd83c7..77d1ed3 100644
--- a/runtime/doc/term.txt
+++ b/runtime/doc/term.txt
@@ -90,6 +90,11 @@
alternate screen. This may slightly change what happens when executing a
shell command or exiting Vim. To avoid this use 't_TI' and 't_TE'.
+Vim will try to detect what keyboard protocol the terminal is using with the
+'t_RK' termcap entry. This is sent after 't_TI', but only when there is no
+work to do (no typeahead and no pending commands). That is to avoid the
+response to end up in a shell command or arrive after Vim exits.
+
*xterm-bracketed-paste*
When the 't_BE' option is set then 't_BE' will be sent to the
terminal when entering "raw" mode and 't_BD' when leaving "raw" mode. The
@@ -388,6 +393,8 @@
xterm and other terminal emulators) The
response is stored in |v:termresponse| |xterm-8bit|
|'ttymouse'| |xterm-codes|
+ t_RK request terminal keyboard protocol state; *t_RK* *'t_RK'*
+ sent after |t_TI|
t_u7 request cursor position (for xterm) *t_u7* *'t_u7'*
see |'ambiwidth'|
The response is stored in |v:termu7resp|