aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-06-25 08:15:45 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-06-27 08:26:10 +0800
commit3b6fb3fefd0bde9bd0700987c4db549a7f4916ec (patch)
tree05064f94e4d71948e72966d23244aa151681eaa7 /test
parent0ca2d11c1f473d9924c261c9dbd4e38730932bb4 (diff)
downloadrneovim-3b6fb3fefd0bde9bd0700987c4db549a7f4916ec.tar.gz
rneovim-3b6fb3fefd0bde9bd0700987c4db549a7f4916ec.tar.bz2
rneovim-3b6fb3fefd0bde9bd0700987c4db549a7f4916ec.zip
vim-patch:9.0.1664: divide by zero when scrolling with 'smoothscroll' set
Problem: Divide by zero when scrolling with 'smoothscroll' set. Solution: Avoid using a negative width. (closes vim/vim#12540, closes vim/vim#12528) https://github.com/vim/vim/commit/8154e642aa476e1a5d3de66c34e8289845b2b797 Co-authored-by: fullwaywang <fullwaywang@tencent.com>
Diffstat (limited to 'test')
-rw-r--r--test/functional/legacy/scroll_opt_spec.lua42
-rw-r--r--test/old/testdir/test_scroll_opt.vim24
2 files changed, 66 insertions, 0 deletions
diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua
index 3b755ff3e8..165570e7ec 100644
--- a/test/functional/legacy/scroll_opt_spec.lua
+++ b/test/functional/legacy/scroll_opt_spec.lua
@@ -939,6 +939,48 @@ describe('smoothscroll', function()
]])
end)
+ -- oldtest: Test_smoothscroll_zero_width_scroll_cursor_bot()
+ it('does not divide by zero in zero-width window', function()
+ screen:try_resize(12, 19)
+ screen:set_default_attr_ids({
+ [1] = {foreground = Screen.colors.Brown}; -- LineNr
+ [2] = {bold = true, reverse = true}; -- StatusLine
+ [3] = {reverse = true}; -- StatusLineNC
+ })
+ exec([[
+ silent normal yy
+ silent normal 19p
+ winsize 0 19
+ vsplit
+ vertical resize 0
+ set foldcolumn=1
+ set number
+ set smoothscroll
+ silent normal 20G
+ ]])
+ screen:expect([[
+ {1: }│ |
+ {1: }│ |
+ {1: }│ |
+ {1: }│ |
+ {1: }│ |
+ {1: }│ |
+ {1: }│ |
+ {1: }│ |
+ {1: }│ |
+ {1: }│ |
+ {1: }│ |
+ {1: }│ |
+ {1: }│ |
+ {1: }│ |
+ {1: }│ |
+ {1: }│ |
+ {1:^ }│ |
+ {2:< }{3:<ame] [+] }|
+ |
+ ]])
+ end)
+
it("works with virt_lines above and below", function()
screen:try_resize(55, 7)
exec([=[
diff --git a/test/old/testdir/test_scroll_opt.vim b/test/old/testdir/test_scroll_opt.vim
index d7be074168..700cc92805 100644
--- a/test/old/testdir/test_scroll_opt.vim
+++ b/test/old/testdir/test_scroll_opt.vim
@@ -836,4 +836,28 @@ func Test_smoothscroll_multi_skipcol()
call StopVimInTerminal(buf)
endfunc
+" this was dividing by zero bug in scroll_cursor_bot
+func Test_smoothscroll_zero_width_scroll_cursor_bot()
+ CheckScreendump
+
+ let lines =<< trim END
+ silent normal yy
+ silent normal 19p
+ winsize 0 19
+ vsplit
+ vertical resize 0
+ set foldcolumn=1
+ set number
+ set smoothscroll
+ silent normal 20G
+ END
+ call writefile(lines, 'XSmoothScrollZeroBot', 'D')
+ let buf = RunVimInTerminal('-u NONE -S XSmoothScrollZeroBot', #{rows: 19, wait_for_ruler: 0})
+ call TermWait(buf, 1000)
+
+ call VerifyScreenDump(buf, 'Test_smoothscroll_zero_bot', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab