diff options
-rw-r--r-- | src/nvim/eval/funcs.c | 2 | ||||
-rw-r--r-- | test/functional/ui/messages_spec.lua | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 609d2f0f7b..dafc27c4df 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -2722,6 +2722,8 @@ static void getchar_common(typval_T *argvars, typval_T *rettv) // getchar(): blocking wait. // TODO(bfredl): deduplicate shared logic with state_enter ? if (!char_avail()) { + // flush output before waiting + ui_flush(); (void)os_inchar(NULL, 0, -1, 0, main_loop.events); if (!multiqueue_empty(main_loop.events)) { state_handle_k_event(); diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index e7eaedba2d..2cff7c1cf4 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1243,6 +1243,19 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim | ]]) end) + + it('echo messages are shown correctly when getchar() immediately follows', function() + feed([[:echo 'foo' | echo 'bar' | call getchar()<CR>]]) + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {3: }| + foo | + bar^ | + ]]) + end) end) describe('ui/ext_messages', function() |