diff --git a/src/nvim/input.c b/src/nvim/input.c index 648fb333ed..165f4169db 100644 --- a/src/nvim/input.c +++ b/src/nvim/input.c @@ -78,6 +78,7 @@ int get_keystroke(MultiQueue *events) int n; int save_mapped_ctrl_c = mapped_ctrl_c; + mod_mask = 0; mapped_ctrl_c = 0; // mappings are not used here while (true) { // flush output before waiting @@ -141,7 +142,7 @@ int get_keystroke(MultiQueue *events) xfree(buf); mapped_ctrl_c = save_mapped_ctrl_c; - return n; + return merge_modifiers(n, &mod_mask); } /// Ask the user for input through a cmdline prompt. diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index ee8034d68f..9fcaee40f4 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -321,6 +321,26 @@ describe('messages', function() {6:-- More --}^ | ]]) + -- Test and as keycodes instead of raw control chars. + feed('') + screen:expect([[ + {8: 80 }80 | + {8: 81 }81 | + {8: 82 }82 | + {8: 83 }83 | + {8: 84 }84 | + {6:-- More --}^ | + ]]) + feed('') + screen:expect([[ + {8: 75 }75 | + {8: 76 }76 | + {8: 77 }77 | + {8: 78 }78 | + {8: 79 }79 | + {6:-- More --}^ | + ]]) + -- Up all the way with 'g'. feed('g') screen:expect([[ diff --git a/test/old/testdir/test_messages.vim b/test/old/testdir/test_messages.vim index b57cd6e294..d221e56c58 100644 --- a/test/old/testdir/test_messages.vim +++ b/test/old/testdir/test_messages.vim @@ -218,6 +218,7 @@ func Test_message_more() CheckRunVimInTerminal let buf = RunVimInTerminal('', {'rows': 6}) + let chan = buf->term_getjob()->job_getchannel() call term_sendkeys(buf, ":call setline(1, range(1, 100))\n") call term_sendkeys(buf, ":%pfoo\\\#") @@ -281,6 +282,19 @@ func Test_message_more() call term_sendkeys(buf, 'u') call WaitForAssert({-> assert_equal(' 79 79', term_getline(buf, 5))}) + " Test and with different keyboard protocols. + for [ctrl_f, ctrl_b] in [ + \ [GetEscCodeCSI27('f', 5), GetEscCodeCSI27('b', 5)], + \ [GetEscCodeCSI27('F', 5), GetEscCodeCSI27('B', 5)], + \ [GetEscCodeCSIu('f', 5), GetEscCodeCSIu('b', 5)], + \ [GetEscCodeCSIu('F', 5), GetEscCodeCSIu('B', 5)], + \ ] + call ch_sendraw(chan, ctrl_f) + call WaitForAssert({-> assert_equal(' 84 84', term_getline(buf, 5))}) + call ch_sendraw(chan, ctrl_b) + call WaitForAssert({-> assert_equal(' 79 79', term_getline(buf, 5))}) + endfor + " Up all the way with 'g'. call term_sendkeys(buf, 'g') call WaitForAssert({-> assert_equal(' 4 4', term_getline(buf, 5))}) @@ -294,6 +308,7 @@ func Test_message_more() call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))}) call term_sendkeys(buf, 'f') call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))}) + call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))}) call term_sendkeys(buf, "\") call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))}) call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))})