diff options
-rw-r--r-- | src/nvim/state.c | 7 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/ui/input_spec.lua | 44 | ||||
-rw-r--r-- | test/functional/vimscript/timer_spec.lua | 2 |
4 files changed, 64 insertions, 1 deletions
diff --git a/src/nvim/state.c b/src/nvim/state.c index f9a3aaab7f..3a7636085b 100644 --- a/src/nvim/state.c +++ b/src/nvim/state.c @@ -15,6 +15,7 @@ #include "nvim/option.h" #include "nvim/option_defs.h" #include "nvim/os/input.h" +#include "nvim/screen.h" #include "nvim/state.h" #include "nvim/ui.h" #include "nvim/vim.h" @@ -54,6 +55,12 @@ getkey: // Event was made available after the last multiqueue_process_events call key = K_EVENT; } else { + // Duplicate display updating logic in vgetorpeek() + if (((State & INSERT) != 0 || p_lz) && (State & CMDLINE) == 0 + && must_redraw != 0 && !need_wait_return) { + update_screen(0); + setcursor(); // put cursor back where it belongs + } // Flush screen updates before blocking ui_flush(); // Call `os_inchar` directly to block for events or user input without diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index ed9d915954..e6ed0f939b 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -1589,6 +1589,18 @@ describe('API', function() feed(':digraphs<cr>') eq({mode='rm', blocking=true}, nvim("get_mode")) end) + + it('after <Nop> mapping returns blocking=false #17257', function() + command('nnoremap <F2> <Nop>') + feed('<F2>') + eq({mode='n', blocking=false}, nvim("get_mode")) + end) + + it('after empty string <expr> mapping returns blocking=false #17257', function() + command('nnoremap <expr> <F2> ""') + feed('<F2>') + eq({mode='n', blocking=false}, nvim("get_mode")) + end) end) describe('RPC (K_EVENT)', function() diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index f5ae228b1e..9df7531016 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -320,3 +320,47 @@ describe("event processing and input", function() eq({'notification', 'stop', {}}, next_msg()) end) end) + +describe('display is updated', function() + local screen + before_each(function() + screen = Screen.new(60, 8) + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText + [2] = {bold = true}, -- ModeMsg + }) + screen:attach() + end) + + it('in Insert mode after <Nop> mapping #17911', function() + command('imap <Plug>test <Nop>') + command('imap <F2> abc<CR><Plug>test') + feed('i<F2>') + screen:expect([[ + abc | + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + end) + + it('in Insert mode after empty string <expr> mapping #17911', function() + command('imap <expr> <Plug>test ""') + command('imap <F2> abc<CR><Plug>test') + feed('i<F2>') + screen:expect([[ + abc | + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]) + end) +end) diff --git a/test/functional/vimscript/timer_spec.lua b/test/functional/vimscript/timer_spec.lua index 25e46062b7..20f2afb20f 100644 --- a/test/functional/vimscript/timer_spec.lua +++ b/test/functional/vimscript/timer_spec.lua @@ -273,7 +273,7 @@ describe('timers', function() eq("Vim(call):E48: Not allowed in sandbox", exc_exec("sandbox call timer_start(0, 'Scary')")) end) - it('can be triggered after an empty string <expr> mapping', function() + it('can be triggered after an empty string <expr> mapping #17257', function() local screen = Screen.new(40, 6) screen:attach() command([=[imap <expr> <F2> [timer_start(0, { _ -> execute("throw 'x'", "") }), ''][-1]]=]) |