Skip to content

Commit e0f8691

Browse files
committed
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.
1 parent ad60898 commit e0f8691

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

Diff for: src/move.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,7 @@ scrolldown(
17341734
col -= width1;
17351735
++row;
17361736
}
1737-
if (col > width2)
1737+
if (col > width2 && width2 > 0)
17381738
{
17391739
row += col / width2;
17401740
col = col % width2;

Diff for: src/testdir/test_window_cmd.vim

+29-10
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,7 @@ func Test_splitkeep_options()
17721772
let &t_WS = save_WS
17731773
endfunc
17741774

1775-
function Test_splitkeep_cmdwin_cursor_position()
1775+
func Test_splitkeep_cmdwin_cursor_position()
17761776
set splitkeep=screen
17771777
call setline(1, range(&lines))
17781778

@@ -1797,9 +1797,9 @@ function Test_splitkeep_cmdwin_cursor_position()
17971797

17981798
%bwipeout!
17991799
set splitkeep&
1800-
endfunction
1800+
endfunc
18011801

1802-
function Test_splitkeep_misc()
1802+
func Test_splitkeep_misc()
18031803
set splitkeep=screen
18041804
set splitbelow
18051805

@@ -1832,7 +1832,7 @@ function Test_splitkeep_misc()
18321832
set splitkeep&
18331833
endfunc
18341834

1835-
function Test_splitkeep_callback()
1835+
func Test_splitkeep_callback()
18361836
CheckScreendump
18371837
let lines =<< trim END
18381838
set splitkeep=screen
@@ -1865,7 +1865,7 @@ function Test_splitkeep_callback()
18651865
call StopVimInTerminal(buf)
18661866
endfunc
18671867

1868-
function Test_splitkeep_fold()
1868+
func Test_splitkeep_fold()
18691869
CheckScreendump
18701870

18711871
let lines =<< trim END
@@ -1895,9 +1895,9 @@ function Test_splitkeep_fold()
18951895
call VerifyScreenDump(buf, 'Test_splitkeep_fold_4', {})
18961896

18971897
call StopVimInTerminal(buf)
1898-
endfunction
1898+
endfunc
18991899

1900-
function Test_splitkeep_status()
1900+
func Test_splitkeep_status()
19011901
CheckScreendump
19021902

19031903
let lines =<< trim END
@@ -1915,9 +1915,9 @@ function Test_splitkeep_status()
19151915
call VerifyScreenDump(buf, 'Test_splitkeep_status_1', {})
19161916

19171917
call StopVimInTerminal(buf)
1918-
endfunction
1918+
endfunc
19191919

1920-
function Test_new_help_window_on_error()
1920+
func Test_new_help_window_on_error()
19211921
help change.txt
19221922
execute "normal! /CTRL-@\<CR>"
19231923
silent! execute "normal! \<C-W>]"
@@ -1927,7 +1927,26 @@ function Test_new_help_window_on_error()
19271927

19281928
call assert_equal(wincount, winnr('$'))
19291929
call assert_equal(expand("<cword>"), "'mod'")
1930-
endfunction
1930+
endfunc
1931+
1932+
func Test_smoothscroll_in_zero_width_window()
1933+
let save_lines = &lines
1934+
let save_columns = &columns
1935+
1936+
winsize 0 24
1937+
set cpo+=n
1938+
exe "noremap 0 \<C-W>n\<C-W>L"
1939+
norm 000000
1940+
set number smoothscroll
1941+
exe "norm \<C-Y>"
1942+
1943+
only!
1944+
let &lines = save_lines
1945+
let &columns = save_columns
1946+
set cpo-=n
1947+
unmap 0
1948+
set nonumber nosmoothscroll
1949+
endfunc
19311950

19321951

19331952
" vim: shiftwidth=2 sts=2 expandtab

Diff for: src/version.c

+2
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1367,
698700
/**/
699701
1366,
700702
/**/

0 commit comments

Comments
 (0)