aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/scrollback_spec.lua
diff options
context:
space:
mode:
authorJavier Lopez <graulopezjavier@gmail.com>2022-06-08 19:46:57 -0500
committerGitHub <noreply@github.com>2022-06-08 17:46:57 -0700
commit916d848049979e7b3974fbf4b6fdf2cf58ae98c3 (patch)
treed2a7df62c939f30a6f206f279cc01a74e5e37d2a /test/functional/terminal/scrollback_spec.lua
parent10291bb8541e461cd3b089bb05c1e3b3946955c5 (diff)
downloadrneovim-916d848049979e7b3974fbf4b6fdf2cf58ae98c3.tar.gz
rneovim-916d848049979e7b3974fbf4b6fdf2cf58ae98c3.tar.bz2
rneovim-916d848049979e7b3974fbf4b6fdf2cf58ae98c3.zip
fix(terminal): scrollback delete lines immediately #18832
* on_scrollback_option_changed renamed to adjust_scrollback. The function name did not correspond to what it was doing. It is called unconditionally in every refresh of the terminal unrelated if the scrollback option was changed. * new on_scrollback_option_changed function, which calls refresh_terminal, which then calls adjust_scrollback * terminal_check_size is not the appropriate function to call when the option is changed since it only conditionally adjusts the scrollback. Use the new on_scrollback_option_changed fixes #15477 fixes #11811
Diffstat (limited to 'test/functional/terminal/scrollback_spec.lua')
-rw-r--r--test/functional/terminal/scrollback_spec.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua
index 34fcb6cab9..b1d3b502b2 100644
--- a/test/functional/terminal/scrollback_spec.lua
+++ b/test/functional/terminal/scrollback_spec.lua
@@ -465,6 +465,34 @@ describe("'scrollback' option", function()
matches((iswin() and '^27: line[ ]*$' or '^26: line[ ]*$'), eval("getline(line('w0') - 10)"))
end)
+ it('deletes extra lines immediately', function()
+ -- Scrollback is 10 on screen_setup
+ local screen = thelpers.screen_setup(nil, nil, 30)
+ local lines = {}
+ for i = 1, 30 do
+ table.insert(lines, 'line'..tostring(i))
+ end
+ table.insert(lines, '')
+ feed_data(lines)
+ screen:expect([[
+ line26 |
+ line27 |
+ line28 |
+ line29 |
+ line30 |
+ {1: } |
+ {3:-- TERMINAL --} |
+ ]])
+ local term_height = 6 -- Actual terminal screen height, not the scrollback
+ -- Initial
+ local scrollback = curbufmeths.get_option('scrollback')
+ eq(scrollback + term_height, eval('line("$")'))
+ -- Reduction
+ scrollback = scrollback - 2
+ curbufmeths.set_option('scrollback', scrollback)
+ eq(scrollback + term_height, eval('line("$")'))
+ end)
+
it('defaults to 10000 in :terminal buffers', function()
set_fake_shell()
command('terminal')