aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2019-06-16 19:48:46 +0200
committerGitHub <noreply@github.com>2019-06-16 19:48:46 +0200
commit491a3210a9b8e67fc91817659fda27585a25e4e1 (patch)
treef8711a4ac4c2063bcff7b6a5488d0fda45240eb4
parentd792d4ec06cb21d4cb71fd28498a8cae2a4b5c95 (diff)
downloadrneovim-491a3210a9b8e67fc91817659fda27585a25e4e1.tar.gz
rneovim-491a3210a9b8e67fc91817659fda27585a25e4e1.tar.bz2
rneovim-491a3210a9b8e67fc91817659fda27585a25e4e1.zip
vim-patch:8.1.1003: playing back recorded key sequence mistakes key code (#10155)
Problem: Playing back recorded key sequence mistakes key code. Solution: Insert a <Nop> after the <Esc>. (closes vim/vim#4068) https://github.com/vim/vim/commit/6edbbd8114320089c0e603e033775d9dd34cb10a
-rw-r--r--src/nvim/getchar.c11
-rw-r--r--src/nvim/testdir/test_registers.vim14
2 files changed, 25 insertions, 0 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 7e4a0e1321..277af74897 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -2342,6 +2342,17 @@ static int vgetorpeek(int advance)
}
}
+ 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;
return c;
diff --git a/src/nvim/testdir/test_registers.vim b/src/nvim/testdir/test_registers.vim
index d7b6de5652..414244768a 100644
--- a/src/nvim/testdir/test_registers.vim
+++ b/src/nvim/testdir/test_registers.vim
@@ -63,3 +63,17 @@ func Test_display_registers()
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