forked from aniani/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 #12540, closes #12528)
This commit is contained in:
committed by
Bram Moolenaar
parent
c9a4a8ab28
commit
8154e642aa
23
src/move.c
23
src/move.c
@@ -2591,17 +2591,20 @@ scroll_cursor_bot(int min_scroll, int set_topbot)
|
|||||||
(curwin, curwin->w_topline, FALSE);
|
(curwin, curwin->w_topline, FALSE);
|
||||||
int skip_lines = 0;
|
int skip_lines = 0;
|
||||||
int width1 = curwin->w_width - curwin_col_off();
|
int width1 = curwin->w_width - curwin_col_off();
|
||||||
int width2 = width1 + curwin_col_off2();
|
if (width1 > 0)
|
||||||
// similar formula is used in curs_columns()
|
|
||||||
if (curwin->w_skipcol > width1)
|
|
||||||
skip_lines += (curwin->w_skipcol - width1) / width2 + 1;
|
|
||||||
else if (curwin->w_skipcol > 0)
|
|
||||||
skip_lines = 1;
|
|
||||||
|
|
||||||
top_plines -= skip_lines;
|
|
||||||
if (top_plines > curwin->w_height)
|
|
||||||
{
|
{
|
||||||
scrolled += (top_plines - curwin->w_height);
|
int width2 = width1 + curwin_col_off2();
|
||||||
|
// similar formula is used in curs_columns()
|
||||||
|
if (curwin->w_skipcol > width1)
|
||||||
|
skip_lines += (curwin->w_skipcol - width1) / width2 + 1;
|
||||||
|
else if (curwin->w_skipcol > 0)
|
||||||
|
skip_lines = 1;
|
||||||
|
|
||||||
|
top_plines -= skip_lines;
|
||||||
|
if (top_plines > curwin->w_height)
|
||||||
|
{
|
||||||
|
scrolled += (top_plines - curwin->w_height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
src/testdir/dumps/Test_smoothscroll_zero_bot.dump
Normal file
19
src/testdir/dumps/Test_smoothscroll_zero_bot.dump
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
| +0#af5f00255#ffffff0||+1#0000000&| +0&&@9
|
||||||
|
|@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
|@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
|@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
|@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
|@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
|@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
|@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
|@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
|@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
|@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
|@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
|@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
|@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
|@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
|@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
>@+0#4040ff13&||+1#0000000&| +0&&@9
|
||||||
|
|<+3&&| |<+1&&|a|m|e|]| |[|+|]|
|
||||||
|
| +0&&@11
|
@@ -833,4 +833,28 @@ func Test_smoothscroll_multi_skipcol()
|
|||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
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
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1664,
|
||||||
/**/
|
/**/
|
||||||
1663,
|
1663,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user