]> granicus.if.org Git - vim/commitdiff
patch 8.1.1003: playing back recorded key sequence mistakes key code v8.1.1003
authorBram Moolenaar <Bram@vim.org>
Sun, 10 Mar 2019 08:41:51 +0000 (09:41 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 10 Mar 2019 08:41:51 +0000 (09:41 +0100)
Problem:    Playing back recorded key sequence mistakes key code.
Solution:   Insert a <Nop> after the <Esc>. (closes #4068)

src/getchar.c
src/testdir/test_registers.vim
src/version.c

index 4e5c8b68cf57775ab864fca7f7520e8d482272e0..0e9942ba34dae7c7d4115628b5106045b62b0210 100644 (file)
@@ -2913,6 +2913,17 @@ vgetorpeek(int advance)
     if (gui.in_use && shape_changed)
        gui_update_cursor(TRUE, FALSE);
 #endif
+    if (timedout && c == ESC)
+    {
+       char_u nop_buf[3];
+
+       // When recording there will be no timeout.  Add a <Nop> after the ESC
+       // to avoid that it forms a key code with following characters.
+       nop_buf[0] = K_SPECIAL;
+       nop_buf[1] = KS_EXTRA;
+       nop_buf[2] = KE_NOP;
+       gotchars(nop_buf, 3);
+    }
 
     --vgetc_busy;
 
index 1ed0a66d1e7715ef55cce697f4ac5cff6e8133bf..b57555aed46a1ef28e2d8a173efcab8d1a050268 100644 (file)
@@ -146,3 +146,17 @@ func Test_register_one()
 
   bwipe!
 endfunc
+
+" Check that replaying a typed sequence does not use an Esc and following
+" characters as an escape sequence.
+func Test_recording_esc_sequence()
+  new
+  let save_F2 = &t_F2
+  let t_F2 = "\<Esc>OQ"
+  call feedkeys("qqiTest\<Esc>", "xt")
+  call feedkeys("OQuirk\<Esc>q", "xt")
+  call feedkeys("Go\<Esc>@q", "xt")
+  call assert_equal(['Quirk', 'Test', 'Quirk', 'Test'], getline(1, 4))
+  bwipe!
+  let t_F2 = save_F2
+endfunc
index 1d0f90dd18830c69de97dbbf96215c7dd5515dce..5b16760327f7f976ded09e9082c83fabc50ce660 100644 (file)
@@ -779,6 +779,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1003,
 /**/
     1002,
 /**/