diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-11-10 15:24:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-10 15:24:36 +0800 |
commit | d5a85d737aa2a5c3a64ef0aa5b01672b7ed49c09 (patch) | |
tree | d3ade990979b1c8f0ad3890fc8a6eb5b90848f68 /test/functional/ui/messages_spec.lua | |
parent | bf5cf8ae82f2a164fba6ae063e0f5b7cb7c1df7b (diff) | |
download | rneovim-d5a85d737aa2a5c3a64ef0aa5b01672b7ed49c09.tar.gz rneovim-d5a85d737aa2a5c3a64ef0aa5b01672b7ed49c09.tar.bz2 rneovim-d5a85d737aa2a5c3a64ef0aa5b01672b7ed49c09.zip |
fix(f_wait): flush UI before blocking (#25962)
Diffstat (limited to 'test/functional/ui/messages_spec.lua')
-rw-r--r-- | test/functional/ui/messages_spec.lua | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index a5b2474bc5..215e763fd1 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1312,17 +1312,54 @@ 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^ | - ]]) + describe('echo messages are shown when immediately followed by', function() + --- @param to_block string command to cause a blocking wait + --- @param to_unblock number|string number: timeout for blocking screen + --- string: keys to stop the blocking wait + local function test_flush_before_block(to_block, to_unblock) + local timeout = type(to_unblock) == 'number' and to_unblock or nil + exec(([[ + func PrintAndWait() + echon "aaa\nbbb" + %s + echon "\nccc" + endfunc + ]]):format(to_block)) + feed(':call PrintAndWait()<CR>') + screen:expect{grid=[[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {3: }| + aaa | + bbb^ | + ]], timeout=timeout} + if type(to_unblock) == 'string' then + feed(to_unblock) + end + screen:expect{grid=[[ + | + {1:~ }| + {3: }| + aaa | + bbb | + ccc | + {4:Press ENTER or type command to continue}^ | + ]]} + end + + it('getchar()', function() + test_flush_before_block([[call getchar()]], 'k') + end) + + it('wait()', function() + test_flush_before_block([[call wait(300, '0')]], 100) + end) + + it('lua vim.wait()', function() + test_flush_before_block([[lua vim.wait(300, function() end)]], 100) + end) end) it('consecutive calls to win_move_statusline() work after multiline message #21014',function() |