changeset 15995:e7030c0c79cd v8.1.1003

patch 8.1.1003: playing back recorded key sequence mistakes key code commit https://github.com/vim/vim/commit/6edbbd8114320089c0e603e033775d9dd34cb10a Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 10 09:41:51 2019 +0100 patch 8.1.1003: playing back recorded key sequence mistakes key code Problem: Playing back recorded key sequence mistakes key code. Solution: Insert a <Nop> after the <Esc>. (closes https://github.com/vim/vim/issues/4068)
author Bram Moolenaar <Bram@vim.org>
date Sun, 10 Mar 2019 09:45:10 +0100
parents 3a572b46aa03
children a302b487956b
files src/getchar.c src/testdir/test_registers.vim src/version.c
diffstat 3 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -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;
 
--- a/src/testdir/test_registers.vim
+++ b/src/testdir/test_registers.vim
@@ -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
--- a/src/version.c
+++ b/src/version.c
@@ -780,6 +780,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1003,
+/**/
     1002,
 /**/
     1001,