mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.0.1247: divide by zero with 'smoothscroll' set and a narrow window
Problem: Divide by zero with 'smoothscroll' set and a narrow window.
Solution: Bail out when the window is too narrow.
870219c58c
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
9b9ccac625
commit
4e4383ffa2
@ -5657,8 +5657,10 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
local to window
|
local to window
|
||||||
Scrolling works with screen lines. When 'wrap' is set and the first
|
Scrolling works with screen lines. When 'wrap' is set and the first
|
||||||
line in the window wraps part of it may not be visible, as if it is
|
line in the window wraps part of it may not be visible, as if it is
|
||||||
above the window.
|
above the window. "<<<" is displayed at the start of the first line,
|
||||||
NOTE: only partly implemented, works with CTRL-E and CTRL-Y.
|
highlighted with |hl-NonText|.
|
||||||
|
NOTE: only partly implemented, currently works with CTRL-E, CTRL-Y
|
||||||
|
and scrolling with the mouse.
|
||||||
|
|
||||||
*'softtabstop'* *'sts'*
|
*'softtabstop'* *'sts'*
|
||||||
'softtabstop' 'sts' number (default 0)
|
'softtabstop' 'sts' number (default 0)
|
||||||
|
@ -1475,6 +1475,9 @@ void adjust_skipcol(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int width1 = curwin->w_width - curwin_col_off();
|
int width1 = curwin->w_width - curwin_col_off();
|
||||||
|
if (width1 <= 0) {
|
||||||
|
return; // no text will be displayed
|
||||||
|
}
|
||||||
int width2 = width1 + curwin_col_off2();
|
int width2 = width1 + curwin_col_off2();
|
||||||
long so = get_scrolloff_value(curwin);
|
long so = get_scrolloff_value(curwin);
|
||||||
long scrolloff_cols = so == 0 ? 0 : width1 + (so - 1) * width2;
|
long scrolloff_cols = so == 0 ? 0 : width1 + (so - 1) * width2;
|
||||||
|
@ -620,4 +620,30 @@ describe('smoothscroll', function()
|
|||||||
feed('0')
|
feed('0')
|
||||||
screen:expect(s1)
|
screen:expect(s1)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- oldtest: Test_smoothscroll_zero_width()
|
||||||
|
it("does not divide by zero with a narrow window", function()
|
||||||
|
screen:try_resize(12, 2)
|
||||||
|
screen:set_default_attr_ids({
|
||||||
|
[1] = {foreground = Screen.colors.Brown},
|
||||||
|
[2] = {foreground = Screen.colors.Blue1, bold = true},
|
||||||
|
})
|
||||||
|
exec([[
|
||||||
|
call setline(1, ['a'->repeat(100)])
|
||||||
|
set wrap smoothscroll number laststatus=0
|
||||||
|
wincmd v
|
||||||
|
wincmd v
|
||||||
|
wincmd v
|
||||||
|
wincmd v
|
||||||
|
]])
|
||||||
|
screen:expect([[
|
||||||
|
{1: 1^ }│{1: }│{1: }│{1: }│{1: }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
feed('llllllllll<C-W>o')
|
||||||
|
screen:expect([[
|
||||||
|
{2:<<<}{1: }aa^aaaaaa|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
@ -577,5 +577,32 @@ func Test_smoothscroll_mouse_pos()
|
|||||||
"let &ttymouse = save_ttymouse
|
"let &ttymouse = save_ttymouse
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" this was dividing by zero
|
||||||
|
func Test_smoothscrol_zero_width()
|
||||||
|
CheckScreendump
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
winsize 0 0
|
||||||
|
vsplit
|
||||||
|
vsplit
|
||||||
|
vsplit
|
||||||
|
vsplit
|
||||||
|
vsplit
|
||||||
|
sil norm H
|
||||||
|
set wrap
|
||||||
|
set smoothscroll
|
||||||
|
set number
|
||||||
|
END
|
||||||
|
call writefile(lines, 'XSmoothScrollZero', 'D')
|
||||||
|
let buf = RunVimInTerminal('-u NONE -i NONE -n -m -X -Z -e -s -S XSmoothScrollZero', #{rows: 6, cols: 60, wait_for_ruler: 0})
|
||||||
|
call TermWait(buf, 3000)
|
||||||
|
call VerifyScreenDump(buf, 'Test_smoothscroll_zero_1', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, ":sil norm \<C-V>\<C-W>\<C-V>\<C-N>\<CR>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_smoothscroll_zero_2', {})
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Loading…
Reference in New Issue
Block a user