diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2023-04-29 00:16:37 +0200 |
---|---|---|
committer | Luuk van Baal <luukvbaal@gmail.com> | 2023-05-02 13:11:47 +0200 |
commit | 7d5673b18b8b4ff085473b40fce317e760e48ce3 (patch) | |
tree | 31573d1779702caeeafe8ca24cbd7989ada68baf | |
parent | 4e4383ffa2b9ec94e703ecbd6178737fc24f6866 (diff) | |
download | rneovim-7d5673b18b8b4ff085473b40fce317e760e48ce3.tar.gz rneovim-7d5673b18b8b4ff085473b40fce317e760e48ce3.tar.bz2 rneovim-7d5673b18b8b4ff085473b40fce317e760e48ce3.zip |
vim-patch:9.0.1367: divide by zero in zero-width window
Problem: Divide by zero in zero-width window.
Solution: Check the width is positive.
https://github.com/vim/vim/commit/e0f869196930ef5f25a0ac41c9215b09c9ce2d3c
Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r-- | src/nvim/move.c | 2 | ||||
-rw-r--r-- | test/old/testdir/test_window_cmd.vim | 39 |
2 files changed, 30 insertions, 11 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c index e635b381d3..69245f2a67 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1303,7 +1303,7 @@ bool scrolldown(long line_count, int byfold) col -= width1; row++; } - if (col > width2) { + if (col > width2 && width2 > 0) { row += (int)col / width2; col = col % width2; } diff --git a/test/old/testdir/test_window_cmd.vim b/test/old/testdir/test_window_cmd.vim index f938203736..f18d1719c0 100644 --- a/test/old/testdir/test_window_cmd.vim +++ b/test/old/testdir/test_window_cmd.vim @@ -1734,7 +1734,7 @@ func Test_splitkeep_options() " let &t_WS = save_WS endfunc -function Test_splitkeep_cmdwin_cursor_position() +func Test_splitkeep_cmdwin_cursor_position() set splitkeep=screen call setline(1, range(&lines)) @@ -1759,9 +1759,9 @@ function Test_splitkeep_cmdwin_cursor_position() %bwipeout! set splitkeep& -endfunction +endfunc -function Test_splitkeep_misc() +func Test_splitkeep_misc() set splitkeep=screen set splitbelow @@ -1794,7 +1794,7 @@ function Test_splitkeep_misc() set splitkeep& endfunc -function Test_splitkeep_callback() +func Test_splitkeep_callback() CheckScreendump let lines =<< trim END set splitkeep=screen @@ -1827,7 +1827,7 @@ function Test_splitkeep_callback() call StopVimInTerminal(buf) endfunc -function Test_splitkeep_fold() +func Test_splitkeep_fold() CheckScreendump let lines =<< trim END @@ -1857,9 +1857,9 @@ function Test_splitkeep_fold() call VerifyScreenDump(buf, 'Test_splitkeep_fold_4', {}) call StopVimInTerminal(buf) -endfunction +endfunc -function Test_splitkeep_status() +func Test_splitkeep_status() CheckScreendump let lines =<< trim END @@ -1877,9 +1877,9 @@ function Test_splitkeep_status() call VerifyScreenDump(buf, 'Test_splitkeep_status_1', {}) call StopVimInTerminal(buf) -endfunction +endfunc -function Test_new_help_window_on_error() +func Test_new_help_window_on_error() help change.txt execute "normal! /CTRL-@\<CR>" silent! execute "normal! \<C-W>]" @@ -1889,7 +1889,26 @@ function Test_new_help_window_on_error() call assert_equal(wincount, winnr('$')) call assert_equal(expand("<cword>"), "'mod'") -endfunction +endfunc + +func Test_smoothscroll_in_zero_width_window() + let save_lines = &lines + let save_columns = &columns + + winsize 0 24 + set cpo+=n + exe "noremap 0 \<C-W>n\<C-W>L" + norm 000000 + set number smoothscroll + exe "norm \<C-Y>" + + only! + let &lines = save_lines + let &columns = save_columns + set cpo-=n + unmap 0 + set nonumber nosmoothscroll +endfunc " vim: shiftwidth=2 sts=2 expandtab |