]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0954: cannot detect whether modifyOtherKeys is enabled v9.0.0954
authorBram Moolenaar <Bram@vim.org>
Sat, 26 Nov 2022 19:16:48 +0000 (19:16 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 26 Nov 2022 19:16:48 +0000 (19:16 +0000)
Problem:    Cannot detect whether modifyOtherKeys is enabled.
Solution:   Use XTQMODKEYS introduced by xterm version 377 to request the
            modifyOtherKeys level.  Update the keycode check results.

13 files changed:
src/getchar.c
src/globals.h
src/map.c
src/term.c
src/testdir/keycode_check.json
src/testdir/keycode_check.vim
src/testdir/setup.vim
src/testdir/shared.vim
src/testdir/test_mapping.vim
src/testdir/test_modeless.vim
src/testdir/test_normal.vim
src/testdir/test_termcodes.vim
src/version.c

index 1e03b86c32a3f33a950536174c54296043a22b0c..142e394aa6ceebf5aca6a0437c3cf3065d9d205d 100644 (file)
@@ -2463,7 +2463,11 @@ check_simplify_modifier(int max_offset)
     static int
 key_protocol_enabled(void)
 {
-    return seenModifyOtherKeys || kitty_protocol_state == KKPS_ENABLED;
+    // If xterm has responded to XTQMODKEYS it overrules seenModifyOtherKeys.
+    int using_mok = modify_otherkeys_state != MOKS_INITIAL
+                       ? modify_otherkeys_state == MOKS_ENABLED
+                       : seenModifyOtherKeys;
+    return using_mok || kitty_protocol_state == KKPS_ENABLED;
 }
 
 /*
index a5e3982093722eb66da510da27b7b40abd7b349e..d9207b940f70032b586271918b9843e9d53d817d 100644 (file)
@@ -1374,9 +1374,29 @@ EXTERN int reg_executing INIT(= 0);      // register being executed or zero
 EXTERN int pending_end_reg_executing INIT(= 0);
 
 // Set when a modifyOtherKeys sequence was seen, then simplified mappings will
-// no longer be used.
+// no longer be used.  To be combined with modify_otherkeys_state.
 EXTERN int seenModifyOtherKeys INIT(= FALSE);
 
+// The state for the modifyOtherKeys level
+typedef enum {
+    // Initially we have no clue if the protocol is on or off.
+    MOKS_INITIAL,
+    // Used when receiving the state and the level is not two.
+    MOKS_OFF,
+    // Used when receiving the state and the level is two.
+    MOKS_ENABLED,
+    // Used after outputting t_KE when the state was MOKS_ENABLED.  We do not
+    // really know if t_KE actually disabled the protocol, the following t_KI
+    // is expected to request the state, but the response may come only later.
+    MOKS_DISABLED,
+    // Used after outputting t_KE when the state was not MOKS_ENABLED.
+    MOKS_AFTER_T_KE,
+} mokstate_T;
+
+// Set when a response to XTQMODKEYS was received.  Only works for xterm
+// version 377 and later.
+EXTERN mokstate_T modify_otherkeys_state INIT(= MOKS_INITIAL);
+
 // The state for the Kitty keyboard protocol.
 typedef enum {
     // Initially we have no clue if the protocol is on or off.
index ee249c77ae9fce311ffdd55e778e8a947d934c1c..505994a85212db0a4830fb83fe5dfca498f7d4bb 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -315,7 +315,26 @@ list_mappings(
     if (p_verbose > 0 && keyround == 1)
     {
        if (seenModifyOtherKeys)
-           msg_puts(_("Seen modifyOtherKeys: true"));
+           msg_puts(_("Seen modifyOtherKeys: true\n"));
+
+       if (modify_otherkeys_state != MOKS_INITIAL)
+       {
+           char *name = _("Unknown");
+           switch (modify_otherkeys_state)
+           {
+               case MOKS_INITIAL: break;
+               case MOKS_OFF: name = _("Off"); break;
+               case MOKS_ENABLED: name = _("On"); break;
+               case MOKS_DISABLED: name = _("Disabled"); break;
+               case MOKS_AFTER_T_KE: name = _("Cleared"); break;
+           }
+
+           char buf[200];
+           vim_snprintf(buf, sizeof(buf),
+                                   _("modifyOtherKeys detected: %s\n"), name);
+           msg_puts(buf);
+       }
+
        if (kitty_protocol_state != KKPS_INITIAL)
        {
            char *name = _("Unknown");
@@ -329,7 +348,8 @@ list_mappings(
            }
 
            char buf[200];
-           vim_snprintf(buf, sizeof(buf), _("Kitty keyboard protocol: %s"), name);
+           vim_snprintf(buf, sizeof(buf),
+                                    _("Kitty keyboard protocol: %s\n"), name);
            msg_puts(buf);
        }
     }
index ec3c3db5ad4eef4506ed8f09abb9ab4547313c8a..237a3258ae68d142fbe46a856146d15be1edf476 100644 (file)
@@ -450,7 +450,7 @@ static tcap_entry_T builtin_xterm[] = {
     {(int)KS_TI,       "\0337\033[?47h"},
     {(int)KS_TE,       "\033[?47l\0338"},
 #  endif
-    {(int)KS_CTI,      "\033[>4;2m"},
+    {(int)KS_CTI,      "\033[>4;2m\033[?4m"},  // see "builtin_mok2"
     {(int)KS_CTE,      "\033[>4;m"},
     {(int)KS_CIS,      "\033]1;"},
     {(int)KS_CIE,      "\007"},
@@ -591,7 +591,10 @@ static tcap_entry_T builtin_xterm[] = {
  * xterm.
  */
 static tcap_entry_T builtin_mok2[] = {
-    {(int)KS_CTI,      "\033[>4;2m"},
+    // XTQMODKEYS was added in xterm version 377: "CSI ? 4 m" which should
+    // return "{lead} > 4 ; Pv m".  Before version 377 we expect it to have no
+    // effect.
+    {(int)KS_CTI,      "\033[>4;2m\033[?4m"},
     {(int)KS_CTE,      "\033[>4;m"},
 
     {(int)KS_NAME,     NULL}  // end marker
@@ -3661,9 +3664,20 @@ out_str_t_TE(void)
     out_str(T_CTE);
 
     // The seenModifyOtherKeys flag is not reset here.  We do expect t_TE to
-    // disable modifyOtherKeys, but there is no way to detect it's enabled
-    // again after the following t_TI.  We assume that when seenModifyOtherKeys
-    // was set before it will still be valid.
+    // disable modifyOtherKeys, but until Xterm version 377 there is no way to
+    // detect it's enabled again after the following t_TI.  We assume that when
+    // seenModifyOtherKeys was set before it will still be valid.
+
+    // When the modifyOtherKeys level is detected to be 2 we expect t_TE to
+    // disable it.  Remembering that it was detected to be enabled is useful in
+    // some situations.
+    // The following t_TI is expected to request the state and then
+    // modify_otherkeys_state will be set again.
+    if (modify_otherkeys_state == MOKS_ENABLED
+           || modify_otherkeys_state == MOKS_DISABLED)
+       modify_otherkeys_state = MOKS_DISABLED;
+    else if (modify_otherkeys_state != MOKS_INITIAL)
+       modify_otherkeys_state = MOKS_AFTER_T_KE;
 
     // When the kitty keyboard protocol is enabled we expect t_TE to disable
     // it.  Remembering that it was detected to be enabled is useful in some
@@ -5112,6 +5126,8 @@ handle_key_without_modifier(
  * Handle a CSI escape sequence.
  * - Xterm version string.
  *
+ * - Response to XTQMODKEYS: "{lead} > 4 ; Pv m".
+ *
  * - Cursor position report: {lead}{row};{col}R
  *   The final byte must be 'R'. It is used for checking the
  *   ambiguous-width character state.
@@ -5121,6 +5137,7 @@ handle_key_without_modifier(
  * - key with modifiers when modifyOtherKeys is enabled:
  *         {lead}27;{modifier};{key}~
  *         {lead}{key};{modifier}u
+ *
  * Return 0 for no match, -1 for partial match, > 0 for full match.
  */
     static int
@@ -5184,12 +5201,24 @@ handle_csi(
     trail = *ap;
     csi_len = (int)(ap - tp) + 1;
 
+    // Response to XTQMODKEYS: "CSI > 4 ; Pv m" where Pv indicates the
+    // modifyOtherKeys level.  Drop similar responses.
+    if (first == '>' && (argc == 1 || argc == 2) && trail == 'm')
+    {
+       if (arg[0] == 4 && argc == 2)
+           modify_otherkeys_state = arg[1] == 2 ? MOKS_ENABLED : MOKS_OFF;
+
+       key_name[0] = (int)KS_EXTRA;
+       key_name[1] = (int)KE_IGNORE;
+       *slen = csi_len;
+    }
+
     // Cursor position report: Eat it when there are 2 arguments
     // and it ends in 'R'. Also when u7_status is not "sent", it
     // may be from a previous Vim that just exited.  But not for
     // <S-F3>, it sends something similar, check for row and column
     // to make sense.
-    if (first == -1 && argc == 2 && trail == 'R')
+    else if (first == -1 && argc == 2 && trail == 'R')
     {
        handle_u7_response(arg, tp, csi_len);
 
@@ -5822,6 +5851,8 @@ check_termcode(
             *   Also eat other possible responses to t_RV, rxvt returns
             *   "{lead}?1;2c".
             *
+            * - Response to XTQMODKEYS: "{lead} > 4 ; Pv m".
+            *
             * - Cursor position report: {lead}{row};{col}R
             *   The final byte must be 'R'. It is used for checking the
             *   ambiguous-width character state.
index 218859f344bed715a82f9d0102097ff25fc188b9..04b4ac9903785acc7648dd955ebbc613a81eadee 100644 (file)
@@ -1 +1 @@
-{"31kitty":{"Space":"20","version":"1b5b3e313b343030303b323163","C-Tab":"","A-Esc":"1b5b32373b313175","C-Space":"1b5b33323b3575","status":"1b5b3f3175","S-C-I":"1b5b3130353b3675","C-I":"1b5b3130353b3575","S-Tab":"1b5b393b3275","Tab":"09","resource":"","A-Tab":"1b5b393b313175","S-Space":"20","C-Esc":"1b5b32373b3575","protocol":"kitty","A-Space":"1b5b33323b313175","S-Esc":"1b5b32373b3275","Esc":"1b5b323775"},"32libvterm":{"Space":"20","version":"1b5b3e303b3130303b3063","C-Tab":"1b5b393b3575","A-Esc":"1b5b32373b3375","C-Space":"1b5b33323b3575","status":"1b5b3f3175","S-C-I":"1b5b3130353b3675","C-I":"1b5b3130353b3575","S-Tab":"1b5b393b3275","Tab":"09","resource":"","A-Tab":"1b5b393b3375","S-Space":"1b5b33323b3275","C-Esc":"1b5b32373b3575","protocol":"kitty","A-Space":"1b5b33323b3375","S-Esc":"1b5b323775","Esc":"1b5b323775"},"22libvterm":{"Space":"20","version":"1b5b3e303b3130303b3063","C-Tab":"1b5b32373b353b397e","A-Esc":"1b5b32373b333b32377e","C-Space":"1b5b32373b353b33327e","status":"","S-C-I":"1b5b32373b363b37337e","C-I":"1b5b32373b353b3130357e","S-Tab":"1b5b5a","Tab":"09","resource":"","A-Tab":"1b5b32373b333b397e","S-Space":"1b5b32373b323b33327e","C-Esc":"1b5b32373b353b32377e","protocol":"mok2","A-Space":"1b5b32373b333b33327e","S-Esc":"1b","Esc":"1b"},"13kitty":{"Space":"20","version":"1b5b3e313b343030303b323163","C-Tab":"","A-Esc":"1b1b","status":"","S-C-I":"1b5b3130353b3675","C-I":"09","S-Tab":"1b5b5a","Tab":"09","resource":"","A-Tab":"1b09","S-Space":"20","C-Esc":"1b","protocol":"none","A-Space":"1b5b33323b313175","S-Esc":"1b","Esc":"1b"},"21xterm":{"Space":"20","version":"1b5b3e34313b3335363b3063","C-Tab":"1b5b32373b353b397e","A-Esc":"1b5b32373b333b32377e","C-Space":"1b5b32373b353b33327e","status":"","S-C-I":"1b5b32373b363b37337e","C-I":"1b5b32373b353b3130357e","S-Tab":"1b5b5a","Tab":"09","resource":"=30","A-Tab":"1b5b32373b333b397e","S-Space":"1b5b32373b323b33327e","C-Esc":"1b5b32373b353b32377e","protocol":"mok2","A-Space":"1b5b32373b333b33327e","S-Esc":"1b","Esc":"1b"},"12libvterm":{"Space":"20","version":"1b5b3e303b3130303b3063","C-Tab":"1b5b393b3575","A-Esc":"9b00","status":"","S-C-I":"1b5b5a","C-I":"09","S-Tab":"1b5b5a","Tab":"09","S-Space":"1b5b33323b3275","A-Tab":"8900","resource":"","C-Esc":"1b5b32373b3575","protocol":"none","A-Space":"a000","S-Esc":"1b","Esc":"1b"},"11xterm":{"Space":"20","version":"1b5b3e34313b3335363b3063","C-Tab":"09","A-Esc":"9b00","status":"","S-C-I":"09","C-I":"09","S-Tab":"1b5b5a","Tab":"09","S-Space":"20","A-Tab":"8900","C-Esc":"1b","protocol":"none","A-Space":"a000","S-Esc":"1b","Esc":"1b"}}
+{"31kitty":{"Space":"20","version":"1b5b3e313b343030303b323163","C-Tab":"","A-Esc":"1b5b32373b313175","C-Space":"1b5b33323b3575","status":"1b5b3f3175","S-C-I":"1b5b3130353b3675","C-I":"1b5b3130353b3575","S-Tab":"1b5b393b3275","Tab":"09","resource":"","A-Tab":"1b5b393b313175","S-Space":"20","C-Esc":"1b5b32373b3575","protocol":"kitty","A-Space":"1b5b33323b313175","S-Esc":"1b5b32373b3275","Esc":"1b5b323775"},"32libvterm":{"Space":"20","version":"1b5b3e303b3130303b3063","C-Tab":"1b5b393b3575","A-Esc":"1b5b32373b3375","C-Space":"1b5b33323b3575","status":"1b5b3f3175","S-C-I":"1b5b3130353b3675","C-I":"1b5b3130353b3575","S-Tab":"1b5b393b3275","Tab":"09","resource":"","A-Tab":"1b5b393b3375","S-Space":"1b5b33323b3275","C-Esc":"1b5b32373b3575","protocol":"kitty","A-Space":"1b5b33323b3375","S-Esc":"1b5b323775","Esc":"1b5b323775"},"22libvterm":{"Space":"20","version":"1b5b3e303b3130303b3063","C-Tab":"1b5b32373b353b397e","A-Esc":"1b5b32373b333b32377e","C-Space":"1b5b32373b353b33327e","status":"","S-C-I":"1b5b32373b363b37337e","C-I":"1b5b32373b353b3130357e","S-Tab":"1b5b5a","Tab":"09","resource":"","A-Tab":"1b5b32373b333b397e","S-Space":"1b5b32373b323b33327e","C-Esc":"1b5b32373b353b32377e","protocol":"mok2","A-Space":"1b5b32373b333b33327e","S-Esc":"1b5b32373b323b32377e","Esc":"1b"},"13kitty":{"Space":"20","version":"1b5b3e313b343030303b323163","C-Tab":"","A-Esc":"1b1b","status":"","S-C-I":"1b5b3130353b3675","C-I":"09","S-Tab":"1b5b5a","Tab":"09","resource":"","A-Tab":"1b09","S-Space":"20","C-Esc":"1b","protocol":"none","A-Space":"1b5b33323b313175","S-Esc":"1b","Esc":"1b"},"21xterm":{"Space":"20","modkeys":"2","version":"1b5b3e34313b3337373b3063","C-Tab":"1b5b32373b353b397e","A-Esc":"1b5b32373b333b32377e","C-Space":"1b5b32373b353b33327e","status":"","S-C-I":"1b5b32373b363b37337e","C-I":"1b5b32373b353b3130357e","S-Tab":"1b5b5a","Tab":"09","resource":"=30","A-Tab":"1b5b32373b333b397e","S-Space":"1b5b32373b323b33327e","C-Esc":"1b5b32373b353b32377e","protocol":"mok2","A-Space":"1b5b32373b333b33327e","S-Esc":"1b5b32373b323b32377e","Esc":"1b"},"12libvterm":{"Space":"20","version":"1b5b3e303b3130303b3063","C-Tab":"1b5b393b3575","A-Esc":"9b00","status":"","S-C-I":"1b5b5a","C-I":"09","S-Tab":"1b5b5a","Tab":"09","S-Space":"1b5b33323b3275","A-Tab":"8900","resource":"","C-Esc":"1b5b32373b3575","protocol":"none","A-Space":"a000","S-Esc":"1b","Esc":"1b"},"11xterm":{"Space":"20","version":"1b5b3e34313b3337373b3063","C-Tab":"09","A-Esc":"9b00","status":"","S-C-I":"09","C-I":"09","S-Tab":"1b5b5a","Tab":"09","resource":"","A-Tab":"8900","S-Space":"20","C-Esc":"1b","protocol":"none","A-Space":"a000","S-Esc":"1b","Esc":"1b"}}
index d754490a3eb4b4d1937206f7d18123471f9ac930..ca759ca50443e09507ea997d30ffb90090795a8a 100644 (file)
@@ -134,7 +134,7 @@ def ActionList()
   endif
   sort(terms)
 
-  var items = ['protocol', 'version', 'status', 'resource']
+  var items = ['protocol', 'version', 'status', 'modkeys']
              + key_entries->copy()->map((_, v) => v[1])
 
   # For each terminal compute the needed width, add two.
@@ -198,9 +198,8 @@ def DoTerm(name: string)
   if proto == 1
     &t_TI = ""
   elseif proto == 2
-    # Enable modifyOtherKeys level 2
-    # Request the resource value: DCS + Q modifyOtherKeys ST
-    &t_TI = "\<Esc>[>4;2m" .. "\<Esc>P+Q6d6f646966794f746865724b657973\<Esc>\\"
+    # Enable modifyOtherKeys level 2.  Request the XTQMODKEYS value.
+    &t_TI = "\<Esc>[>4;2m" .. "\<Esc>[?4m"
     proto_name = 'mok2'
   elseif proto == 3
     # Enable Kitty keyboard protocol and request the status
@@ -218,10 +217,10 @@ def DoTerm(name: string)
   # Pattern that matches the line with the version response.
   const version_pattern = "\<Esc>\\[>\\d\\+;\\d\\+;\\d*c"
 
-  # Pattern that matches the resource value response:
-  #    DCS 1 + R Pt ST    valid
-  #    DCS 0 + R Pt ST    invalid
-  const resource_pattern = "\<Esc>P[01]+R.*\<Esc>\\\\"
+  # Pattern that matches the XTQMODKEYS response:
+  #    CSI > 4;Pv m
+  # where Pv indicates the modifyOtherKeys level
+  const modkeys_pattern = "\<Esc>\\[>4;\\dm"
 
   # Pattern that matches the line with the status.  Currently what terminals
   # return for the Kitty keyboard protocol.
@@ -264,7 +263,7 @@ def DoTerm(name: string)
   keycodes[name]['protocol'] = proto_name
   keycodes[name]['version'] = ''
   keycodes[name]['status'] = ''
-  keycodes[name]['resource'] = ''
+  keycodes[name]['modkeys'] = ''
 
   # Check the log file for a status and the version response
   ch_logfile('', '')
@@ -275,16 +274,16 @@ def DoTerm(name: string)
     if line =~ 'raw key input'
       var code = substitute(line, '.*raw key input: "\([^"]*\).*', '\1', '')
 
-      # Check for resource value response
-      if code =~ resource_pattern
-       var resource = substitute(code, '.*\(' .. resource_pattern .. '\).*', '\1', '')
-       # use the value as the resource, "=30" means zero
-       resource = substitute(resource, '.*\(=\p\+\).*', '\1', '')
+      # Check for the XTQMODKEYS response.
+      if code =~ modkeys_pattern
+       var modkeys = substitute(code, '.*\(' .. modkeys_pattern .. '\).*', '\1', '')
+       # Get the level out of the response
+       modkeys = substitute(modkeys, '.*4;\(\d\)m', '\1', '')
 
-       if keycodes[name]['resource'] != ''
-         echomsg 'Another resource found after ' .. keycodes[name]['resource']
+       if keycodes[name]['modkeys'] != ''
+         echomsg 'Another modkeys found after ' .. keycodes[name]['modkeys']
        endif
-       keycodes[name]['resource'] = resource
+       keycodes[name]['modkeys'] = modkeys
       endif
 
       # Check for kitty keyboard protocol status
index fca5194abfe5dfa88b6ee2034dfe5a98b7cf9625..5b8f3f110421aacb904c104a072d883df8cb62fa 100644 (file)
@@ -2,6 +2,12 @@
 
 " Only load this once.
 if 1
+
+  " When using xterm version 377 the response to the modifyOtherKeys status
+  " interferes with some tests.  Remove the request from the t_TI termcap
+  " entry.
+  let &t_TI = substitute(&t_TI, "\<Esc>\\[?4m", '', '')
+
   if exists('s:did_load')
     finish
   endif
index 1b41c6ff3e1f5c280bb3c865560082c62f02cd7a..d373a6e7407b4b0cdda9bd5e20e686d7746749c1 100644 (file)
@@ -7,6 +7,13 @@ endif
 
 source view_util.vim
 
+" When 'term' is changed some status requests may be sent.  The responses may
+" interfere with what is being tested.  A short sleep is used to process any of
+" those responses first.
+func WaitForResponses()
+  sleep 50m
+endfunc
+
 " Get the name of the Python executable.
 " Also keeps it in s:python.
 func PythonProg()
index 4d5b202d40df1ade68e9522194247cca8e817967..4ecdac62dd0983de75594147cafcbb6a557e1ff2 100644 (file)
@@ -478,10 +478,24 @@ func Test_list_mappings()
         \ execute('nmap ,n')->trim()->split("\n"))
 
   " verbose map
-  " first line might be "seen modifyOtherKeys"
   let lines = execute('verbose map ,n')->trim()->split("\n")
+
+  " Remove "Seen modifyOtherKeys" and other optional info.
+  if lines[0] =~ 'Seen modifyOtherKeys'
+    call remove(lines, 0)
+  endif
+  if lines[0] =~ 'modifyOtherKeys detected:'
+    call remove(lines, 0)
+  endif
+  if lines[0] =~ 'Kitty keyboard protocol:'
+    call remove(lines, 0)
+  endif
+  if lines[0] == ''
+    call remove(lines, 0)
+  endif
+
   let index = indexof(lines, 'v:val =~ "Last set"')
-  call assert_inrange(1, 2, index)
+  call assert_equal(1, index)
   call assert_match("\tLast set from .*/test_mapping.vim line \\d\\+$",
         \ lines[index])
 
index 3736f988eae13d89a07f0e19e73ef1306e4edb55..281c2486741a6d3c67c0beec1dd65c22179a2ca8 100644 (file)
@@ -5,6 +5,7 @@ source check.vim
 CheckNotGui
 CheckUnix
 
+source shared.vim
 source mouse.vim
 
 " Test for modeless characterwise selection (single click)
@@ -15,10 +16,15 @@ func Test_modeless_characterwise_selection()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm mousetime=200
+  call WaitForResponses()
+
   new
   call setline(1, ['one two three', 'foo bar baz'])
   redraw!
 
+  " Wait a bit for any terminal responses to get processed.
+  sleep 50m
+
   for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec
     let msg = 'ttymouse=' .. ttymouse_val
     exe 'set ttymouse=' .. ttymouse_val
@@ -250,6 +256,8 @@ func Test_modeless_word_selection()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm mousetime=200
+  call WaitForResponses()
+
   new
   call setline(1, ['one two three', 'foo bar baz'])
   redraw!
@@ -330,6 +338,8 @@ func Test_modeless_line_selection()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm mousetime=200
+  call WaitForResponses()
+
   new
   call setline(1, ['one two three', 'foo bar baz'])
   redraw!
index f7194b6035002f7b198cf0ecd3928c9931d5da04..8f547e3e951c0b6ecbd893e554e4495764c1e24b 100644 (file)
@@ -3102,15 +3102,18 @@ endfunc
 func Test_normal50_commandline()
   CheckFeature timers
   CheckFeature cmdline_hist
+
   func! DoTimerWork(id)
     call assert_equal('[Command Line]', bufname(''))
+
     " should fail, with E11, but does fail with E23?
     "call feedkeys("\<c-^>", 'tm')
 
-    " should also fail with E11
+    " should fail with E11 - "Invalid in command-line window"
     call assert_fails(":wincmd p", 'E11:')
-    " return from commandline window
-    call feedkeys("\<cr>")
+
+    " Return from commandline window.
+    call feedkeys("\<CR>", 't')
   endfunc
 
   let oldlang=v:lang
@@ -3123,7 +3126,9 @@ func Test_normal50_commandline()
   catch /E23/
     " no-op
   endtry
+
   " clean up
+  delfunc DoTimerWork
   set updatetime=4000
   exe "lang" oldlang
   bw!
index 97b06c60659bde2142fcdcc16e94f7e2b733cdfb..a9a19e82361501fe0bd0be87ba33f7dfd594672a 100644 (file)
@@ -17,6 +17,8 @@ func Test_term_mouse_left_click()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm
+  call WaitForResponses()
+
   call setline(1, ['line 1', 'line 2', 'line 3 is a bit longer'])
 
   for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec + g:Ttymouse_netterm
@@ -47,6 +49,7 @@ func Test_xterm_mouse_right_click_extends_visual()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm
+  call WaitForResponses()
 
   for visual_mode in ["v", "V", "\<C-V>"]
     for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec
@@ -118,6 +121,7 @@ func Test_xterm_mouse_tagjump()
   let save_term = &term
   let save_ttymouse = &ttymouse
   set mouse=a term=xterm
+  call WaitForResponses()
 
   for ttymouse_val in g:Ttymouse_values
     let msg = 'ttymouse=' .. ttymouse_val
@@ -192,6 +196,7 @@ func Test_term_mouse_middle_click()
   let save_quotestar = @*
   let save_quoteplus = @+
   set mouse=a term=xterm
+  call WaitForResponses()
 
   for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec
     let msg = 'ttymouse=' .. ttymouse_val
@@ -277,6 +282,7 @@ func Test_term_mouse_middle_click_no_clipboard()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm
+  call WaitForResponses()
 
   for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec
     let msg = 'ttymouse=' .. ttymouse_val
@@ -307,6 +313,7 @@ func Test_term_mouse_middle_click_insert_mode()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm
+  call WaitForResponses()
 
   for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec
     let msg = 'ttymouse=' .. ttymouse_val
@@ -349,6 +356,7 @@ func Test_term_mouse_switch_win_insert_mode()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm ttymouse=xterm2
+  call WaitForResponses()
 
   call feedkeys('ivim' ..
         \ MouseLeftClickCode(8, 6) .. MouseLeftReleaseCode(8, 6) ..
@@ -372,6 +380,8 @@ func Test_mouse_cmdwin_resize()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm ttymouse=xterm2
+  call WaitForResponses()
+
   5new
   redraw!
 
@@ -400,6 +410,8 @@ func Test_1xterm_mouse_wheel()
   let save_wrap = &wrap
   let save_ttymouse = &ttymouse
   set mouse=a term=xterm nowrap
+  call WaitForResponses()
+
   call setline(1, range(100000000000000, 100000000000100))
 
   for ttymouse_val in g:Ttymouse_values
@@ -461,6 +473,8 @@ func Test_term_mouse_drag_beyond_window()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm
+  call WaitForResponses()
+
   let col = 1
   call setline(1, range(1, 100))
 
@@ -546,6 +560,7 @@ func Test_term_mouse_drag_window_separator()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm
+  call WaitForResponses()
 
   for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec
     let msg = 'ttymouse=' .. ttymouse_val
@@ -605,6 +620,7 @@ func Test_term_mouse_drag_statusline()
   call test_override('no_query_mouse', 1)
   let save_laststatus = &laststatus
   set mouse=a term=xterm laststatus=2
+  call WaitForResponses()
 
   for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec
     let msg = 'ttymouse=' .. ttymouse_val
@@ -647,6 +663,8 @@ func Test_term_mouse_click_tab()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm
+  call WaitForResponses()
+
   let row = 1
 
   for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec + g:Ttymouse_netterm
@@ -696,6 +714,8 @@ func Test_term_mouse_click_X_to_close_tab()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm
+  call WaitForResponses()
+
   let row = 1
   let col = &columns
 
@@ -745,6 +765,8 @@ func Test_term_mouse_drag_to_move_tab()
   call test_override('no_query_mouse', 1)
   " Set 'mousetime' to 1 to avoid recognizing a double-click in the loop
   set mouse=a term=xterm mousetime=1
+  call WaitForResponses()
+
   let row = 1
 
   for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec
@@ -820,6 +842,8 @@ func Test_term_mouse_double_click_to_create_tab()
   " Set 'mousetime' to a small value, so that double-click works but we don't
   " have to wait long to avoid a triple-click.
   set mouse=a term=xterm mousetime=200
+  call WaitForResponses()
+
   let row = 1
   let col = 10
 
@@ -877,6 +901,8 @@ func Test_term_mouse_multiple_clicks_to_visually_select()
   " 'mousetime' must be sufficiently large, or else the test is flaky when
   " using a ssh connection with X forwarding; i.e. ssh -X (issue #7563).
   set mouse=a term=xterm mousetime=600
+  call WaitForResponses()
+
   new
 
   for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec
@@ -1002,6 +1028,8 @@ func Test_mouse_alt_leftclick()
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm mousetime=200
   set mousemodel=popup
+  call WaitForResponses()
+
   new
   call setline(1, 'one (two) three')
 
@@ -1036,6 +1064,7 @@ func Test_xterm_mouse_click_in_fold_columns()
   let save_ttymouse = &ttymouse
   let save_foldcolumn = &foldcolumn
   set mouse=a term=xterm foldcolumn=3 ttymouse=xterm2
+  call WaitForResponses()
 
   " Create 2 nested folds.
   call setline(1, range(1, 7))
@@ -1087,6 +1116,8 @@ func Test_term_mouse_click_in_cmdline_to_set_pos()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm
+  call WaitForResponses()
+
   let row = &lines
 
   for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec
@@ -1121,6 +1152,8 @@ func Test_term_mouse_middle_click_in_cmdline_to_paste()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm
+  call WaitForResponses()
+
   let row = &lines
   " Column values does not matter, paste is done at position of cursor.
   let col = 1
@@ -1155,6 +1188,7 @@ func Test_term_mouse_shift_middle_click()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm ttymouse=xterm2 mousemodel=
+  call WaitForResponses()
 
   call test_setmouse(1, 1)
   exe "normal \<S-MiddleMouse>"
@@ -1177,6 +1211,7 @@ func Test_term_mouse_visual_mode()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set term=xterm ttymouse=xterm2
+  call WaitForResponses()
 
   " If visual mode is not present in 'mouse', then left click should not
   " do anything in visal mode.
@@ -1258,6 +1293,7 @@ func Test_term_mouse_popup_menu()
   let save_mousemodel = &mousemodel
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm mousemodel=popup
+  call WaitForResponses()
 
   menu PopUp.foo :let g:menustr = 'foo'<CR>
   menu PopUp.bar :let g:menustr = 'bar'<CR>
@@ -1294,6 +1330,7 @@ func Test_term_mouse_popup_menu_setpos()
   let save_mousemodel = &mousemodel
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm mousemodel=popup_setpos
+  call WaitForResponses()
 
   nmenu PopUp.foo :let g:menustr = 'foo'<CR>
   nmenu PopUp.bar :let g:menustr = 'bar'<CR>
@@ -1416,6 +1453,7 @@ func Test_term_mouse_search()
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm ttymouse=xterm2
   set mousemodel=
+  call WaitForResponses()
 
   " In normal mode, Shift-Left or Shift-Right click should search for the word
   " under the cursor.
@@ -1453,6 +1491,7 @@ func Test_term_mouse_quickfix_window()
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm ttymouse=xterm2
   set mousemodel=
+  call WaitForResponses()
 
   cgetexpr "Xfile1:1:L1"
   copen 5
@@ -1482,6 +1521,7 @@ func Test_term_mouse_help_window()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=h term=xterm mousetime=200
+  call WaitForResponses()
 
   for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec
     let msg = 'ttymouse=' .. ttymouse_val
@@ -1518,6 +1558,7 @@ func Test_mouse_termcodes()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=xterm mousetime=200
+  call WaitForResponses()
 
   new
   for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec + g:Ttymouse_netterm
@@ -1884,6 +1925,8 @@ func Test_xx07_xterm_response()
   " xterm < 95: "xterm" (actually unmodified)
   set t_RV=
   set term=xterm
+  call WaitForResponses()
+
   set t_RV=x
   set ttymouse=xterm
   call test_option_not_set('ttymouse')
@@ -1969,6 +2012,7 @@ func Test_focus_events()
   let save_term = &term
   let save_ttymouse = &ttymouse
   set term=xterm ttymouse=xterm2
+  call WaitForResponses()
 
   au FocusGained * let g:focus_gained += 1
   au FocusLost * let g:focus_lost += 1
@@ -2159,6 +2203,8 @@ func Test_CSIu_keys_without_modifiers()
   " make this execute faster
   set timeoutlen=10
 
+  call WaitForResponses()
+
   " Escape sent as `CSI 27 u` should act as normal escape and not undo
   call setline(1, 'a')
   call feedkeys('a' .. GetEscCodeCSIuWithoutModifier("\e"), 'Lx!')
@@ -2186,6 +2232,7 @@ func Test_ignore_dec_mouse()
   let save_ttymouse = &ttymouse
   call test_override('no_query_mouse', 1)
   set mouse=a term=gnome ttymouse=
+  call WaitForResponses()
 
   execute "set <xF1>=\<Esc>[1;*P"
   nnoremap <S-F1> agot it<Esc>
@@ -2431,6 +2478,9 @@ endfunc
 
 func Test_insert_literal()
   set timeoutlen=10
+
+  call WaitForResponses()
+
   new
   " CTRL-V CTRL-X inserts a ^X
   call feedkeys('a' .. GetEscCodeCSIu('V', '5') .. GetEscCodeCSIu('X', '5') .. "\<Esc>", 'Lx!')
index d16ff108efc5b221de99b6f5a139ce09a3e8c7c9..447392c153480e908c4497cd11e7f8f0b6a26ae2 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    954,
 /**/
     953,
 /**/