diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-03-18 22:25:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-18 22:25:55 +0800 |
commit | e3bd04f2aff738722c06276cc926d4bdd4501402 (patch) | |
tree | 2bd22e459f73952bc4e72a4e70af2d8069e07ca9 /test/functional/ui/messages_spec.lua | |
parent | 5de0482d1abfdc0a4ede1b96f729dae38f1c7c56 (diff) | |
download | rneovim-e3bd04f2aff738722c06276cc926d4bdd4501402.tar.gz rneovim-e3bd04f2aff738722c06276cc926d4bdd4501402.tar.bz2 rneovim-e3bd04f2aff738722c06276cc926d4bdd4501402.zip |
fix(pager): handle consecutive newlines properly (#27913)
Diffstat (limited to 'test/functional/ui/messages_spec.lua')
-rw-r--r-- | test/functional/ui/messages_spec.lua | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 6b71d85861..32d3359a0b 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -10,6 +10,7 @@ local api = helpers.api local async_meths = helpers.async_meths local test_build_dir = helpers.paths.test_build_dir local nvim_prog = helpers.nvim_prog +local testprg = helpers.testprg local exec = helpers.exec local exec_capture = helpers.exec_capture local exc_exec = helpers.exc_exec @@ -2498,6 +2499,178 @@ aliquip ex ea commodo consequat.]] ]], } end) + + it('g< shows blank line from :echo properly', function() + screen:try_resize(60, 8) + feed([[:echo 1 | echo "\n" | echo 2<CR>]]) + screen:expect([[ + | + {1:~ }|*2 + {12: }| + 1 | + | + 2 | + {4:Press ENTER or type command to continue}^ | + ]]) + + feed('<CR>') + screen:expect([[ + ^ | + {1:~ }|*6 + | + ]]) + + feed('g<lt>') + screen:expect([[ + | + {1:~ }| + {12: }| + :echo 1 | echo "\n" | echo 2 | + 1 | + | + 2 | + {4:Press ENTER or type command to continue}^ | + ]]) + + feed('<CR>') + screen:expect([[ + ^ | + {1:~ }|*6 + | + ]]) + end) + + it('scrolling works properly when :echo output ends with newline', function() + screen:try_resize(60, 6) + feed([[:echo range(100)->join("\n") .. "\n"<CR>]]) + screen:expect([[ + 0 | + 1 | + 2 | + 3 | + 4 | + {4:-- More --}^ | + ]]) + feed('G') + screen:expect([[ + 96 | + 97 | + 98 | + 99 | + | + {4:Press ENTER or type command to continue}^ | + ]]) + for _ = 1, 3 do + feed('k') + screen:expect([[ + 95 | + 96 | + 97 | + 98 | + 99 | + {4:-- More --}^ | + ]]) + feed('k') + screen:expect([[ + 94 | + 95 | + 96 | + 97 | + 98 | + {4:-- More --}^ | + ]]) + feed('j') + screen:expect([[ + 95 | + 96 | + 97 | + 98 | + 99 | + {4:-- More --}^ | + ]]) + feed('j') + screen:expect([[ + 96 | + 97 | + 98 | + 99 | + | + {4:-- More --}^ | + ]]) + feed('j') + screen:expect([[ + 96 | + 97 | + 98 | + 99 | + | + {4:Press ENTER or type command to continue}^ | + ]]) + end + end) + + it('scrolling works properly when :!cmd output ends with newline #27902', function() + screen:try_resize(60, 6) + api.nvim_set_option_value('shell', testprg('shell-test'), {}) + api.nvim_set_option_value('shellcmdflag', 'REP 100', {}) + api.nvim_set_option_value('shellxquote', '', {}) -- win: avoid extra quotes + feed([[:!foo<CR>]]) + screen:expect([[ + 96: foo | + 97: foo | + 98: foo | + 99: foo | + | + {4:Press ENTER or type command to continue}^ | + ]]) + for _ = 1, 3 do + feed('k') + screen:expect([[ + 95: foo | + 96: foo | + 97: foo | + 98: foo | + 99: foo | + {4:-- More --}^ | + ]]) + feed('k') + screen:expect([[ + 94: foo | + 95: foo | + 96: foo | + 97: foo | + 98: foo | + {4:-- More --}^ | + ]]) + feed('j') + screen:expect([[ + 95: foo | + 96: foo | + 97: foo | + 98: foo | + 99: foo | + {4:-- More --}^ | + ]]) + feed('j') + screen:expect([[ + 96: foo | + 97: foo | + 98: foo | + 99: foo | + | + {4:-- More --}^ | + ]]) + feed('j') + screen:expect([[ + 96: foo | + 97: foo | + 98: foo | + 99: foo | + | + {4:Press ENTER or type command to continue}^ | + ]]) + end + end) end) it('pager works in headless mode with UI attached', function() |