mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 15:08:35 +00:00
vim-patch:9.0.2145: wrong scrolling in insert mode with smoothscroll (#26375)
Problem: Wrong scrolling in Insert mode with 'smoothscroll' at the
bottom of the window.
Solution: Don't use set_topline() when 'smoothscroll' is set.
fixes: vim/vim#13612
closes: vim/vim#13613
5b4d1fcbf0
This commit is contained in:
@@ -2644,6 +2644,8 @@ int number_width(win_T *wp)
|
|||||||
/// e.g. if must_redraw is UPD_CLEAR, type UPD_NOT_VALID will do nothing.
|
/// e.g. if must_redraw is UPD_CLEAR, type UPD_NOT_VALID will do nothing.
|
||||||
void redraw_later(win_T *wp, int type)
|
void redraw_later(win_T *wp, int type)
|
||||||
{
|
{
|
||||||
|
// curwin may have been set to NULL when exiting
|
||||||
|
assert(wp != NULL || exiting);
|
||||||
if (!exiting && wp->w_redr_type < type) {
|
if (!exiting && wp->w_redr_type < type) {
|
||||||
wp->w_redr_type = type;
|
wp->w_redr_type = type;
|
||||||
if (type >= UPD_NOT_VALID) {
|
if (type >= UPD_NOT_VALID) {
|
||||||
|
@@ -444,8 +444,11 @@ static int insert_check(VimState *state)
|
|||||||
// is detected when the cursor column is smaller after inserting something.
|
// is detected when the cursor column is smaller after inserting something.
|
||||||
// Don't do this when the topline changed already, it has already been
|
// Don't do this when the topline changed already, it has already been
|
||||||
// adjusted (by insertchar() calling open_line())).
|
// adjusted (by insertchar() calling open_line())).
|
||||||
|
// Also don't do this when 'smoothscroll' is set, as the window should then
|
||||||
|
// be scrolled by screen lines.
|
||||||
if (curbuf->b_mod_set
|
if (curbuf->b_mod_set
|
||||||
&& curwin->w_p_wrap
|
&& curwin->w_p_wrap
|
||||||
|
&& !curwin->w_p_sms
|
||||||
&& !s->did_backspace
|
&& !s->did_backspace
|
||||||
&& curwin->w_topline == s->old_topline
|
&& curwin->w_topline == s->old_topline
|
||||||
&& curwin->w_topfill == s->old_topfill) {
|
&& curwin->w_topfill == s->old_topfill) {
|
||||||
|
@@ -1096,6 +1096,26 @@ describe('smoothscroll', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('works in Insert mode at bottom of window', function()
|
||||||
|
screen:try_resize(40, 9)
|
||||||
|
exec([[
|
||||||
|
call setline(1, repeat([repeat('A very long line ...', 10)], 5))
|
||||||
|
set wrap smoothscroll scrolloff=0
|
||||||
|
]])
|
||||||
|
feed('Go123456789<CR>')
|
||||||
|
screen:expect([[
|
||||||
|
<<<ery long line ...A very long line ...|
|
||||||
|
A very long line ...A very long line ...|
|
||||||
|
A very long line ...A very long line ...|
|
||||||
|
A very long line ...A very long line ...|
|
||||||
|
A very long line ...A very long line ...|
|
||||||
|
A very long line ...A very long line ...|
|
||||||
|
123456789 |
|
||||||
|
^ |
|
||||||
|
-- INSERT -- |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
it('<<< marker shows with tabline, winbar and splits', function()
|
it('<<< marker shows with tabline, winbar and splits', function()
|
||||||
screen:try_resize(40, 12)
|
screen:try_resize(40, 12)
|
||||||
exec([[
|
exec([[
|
||||||
|
@@ -923,7 +923,7 @@ func Test_smoothscroll_cursor_top()
|
|||||||
exe "norm G3\<C-E>k"
|
exe "norm G3\<C-E>k"
|
||||||
END
|
END
|
||||||
call writefile(lines, 'XSmoothScrollCursorTop', 'D')
|
call writefile(lines, 'XSmoothScrollCursorTop', 'D')
|
||||||
let buf = RunVimInTerminal('-u NONE -S XSmoothScrollCursorTop', #{rows: 12, cols:40})
|
let buf = RunVimInTerminal('-u NONE -S XSmoothScrollCursorTop', #{rows: 12, cols: 40})
|
||||||
call VerifyScreenDump(buf, 'Test_smoothscroll_cursor_top', {})
|
call VerifyScreenDump(buf, 'Test_smoothscroll_cursor_top', {})
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
@@ -942,10 +942,25 @@ func Test_smoothscroll_crash()
|
|||||||
exe "norm! 0\<c-e>"
|
exe "norm! 0\<c-e>"
|
||||||
END
|
END
|
||||||
call writefile(lines, 'XSmoothScrollCrash', 'D')
|
call writefile(lines, 'XSmoothScrollCrash', 'D')
|
||||||
let buf = RunVimInTerminal('-u NONE -S XSmoothScrollCrash', #{rows: 12, cols:40})
|
let buf = RunVimInTerminal('-u NONE -S XSmoothScrollCrash', #{rows: 12, cols: 40})
|
||||||
call term_sendkeys(buf, "2\<C-E>\<C-L>")
|
call term_sendkeys(buf, "2\<C-E>\<C-L>")
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_smoothscroll_insert_bottom()
|
||||||
|
CheckScreendump
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
call setline(1, repeat([repeat('A very long line ...', 10)], 5))
|
||||||
|
set wrap smoothscroll scrolloff=0
|
||||||
|
END
|
||||||
|
call writefile(lines, 'XSmoothScrollInsertBottom', 'D')
|
||||||
|
let buf = RunVimInTerminal('-u NONE -S XSmoothScrollInsertBottom', #{rows: 9, cols: 40})
|
||||||
|
call term_sendkeys(buf, "Go123456789\<CR>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_smoothscroll_insert_bottom', {})
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Reference in New Issue
Block a user