mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #28790 from luukvbaal/vim-9.1.0414
vim-patch:9.1.{0414,0416}
This commit is contained in:
commit
5f9e7edae6
@ -1579,8 +1579,20 @@ void adjust_skipcol(void)
|
||||
redraw_later(curwin, UPD_NOT_VALID);
|
||||
return; // don't scroll in the other direction now
|
||||
}
|
||||
colnr_T col = curwin->w_virtcol - curwin->w_skipcol + scrolloff_cols;
|
||||
int row = 0;
|
||||
colnr_T col = curwin->w_virtcol + scrolloff_cols;
|
||||
|
||||
// Avoid adjusting for 'scrolloff' beyond the text line height.
|
||||
if (scrolloff_cols > 0) {
|
||||
int size = win_linetabsize(curwin, curwin->w_topline,
|
||||
ml_get(curwin->w_topline), (colnr_T)MAXCOL);
|
||||
size = width1 + width2 * ((size - width1 + width2 - 1) / width2);
|
||||
while (col > size) {
|
||||
col -= width2;
|
||||
}
|
||||
}
|
||||
col -= curwin->w_skipcol;
|
||||
|
||||
if (col >= width1) {
|
||||
col -= width1;
|
||||
row++;
|
||||
@ -2114,7 +2126,10 @@ void scroll_cursor_bot(win_T *wp, int min_scroll, bool set_topbot)
|
||||
wp->w_valid |= VALID_TOPLINE;
|
||||
wp->w_viewport_invalid = true;
|
||||
|
||||
cursor_correct_sms(wp);
|
||||
// Make sure cursor is still visible after adjusting skipcol for "zb".
|
||||
if (set_topbot) {
|
||||
cursor_correct_sms(wp);
|
||||
}
|
||||
}
|
||||
|
||||
/// Recompute topline to put the cursor halfway across the window
|
||||
|
@ -1197,4 +1197,91 @@ describe('smoothscroll', function()
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
it('works with very long line and scrolloff', function()
|
||||
screen:try_resize(40, 8)
|
||||
exec([[
|
||||
set smoothscroll scrolloff=3
|
||||
call setline(1, ['one', 'two long '->repeat(100), 'three', 'four', 'five', 'six'])
|
||||
]])
|
||||
--FIXME: incorrect screen due to reset_skipcol()/curs_columns() shenanigans
|
||||
feed(':norm j721|<CR>')
|
||||
screen:expect([[
|
||||
two long two long two long two long two |
|
||||
long two long two long two long two long|
|
||||
two long two long two long two long two|
|
||||
^ long two long two long two long two lon|
|
||||
g two long two long two long two long tw|
|
||||
o long two long two long two long two lo|
|
||||
ng two long two long two long two long t|
|
||||
:norm j721| |
|
||||
]])
|
||||
feed('gj')
|
||||
screen:expect([[
|
||||
{1:<<<}two long two long two long two long t|
|
||||
wo long two long two long two long two l|
|
||||
ong two long two long two long two long |
|
||||
two long two long two long two long two |
|
||||
^long two long two long two long two long|
|
||||
two long two long two long two long two|
|
||||
long two long two long two long two lon|
|
||||
:norm j721| |
|
||||
]])
|
||||
feed('gj')
|
||||
screen:expect([[
|
||||
{1:<<<}long two long two long two long two l|
|
||||
ong two long two long two long two long |
|
||||
two long two long two long two long two |
|
||||
long two long two long two long two long|
|
||||
^ two long two long two long two long two|
|
||||
long two long two long two long two lon|
|
||||
g two long two long |
|
||||
:norm j721| |
|
||||
]])
|
||||
feed('gj')
|
||||
screen:expect([[
|
||||
{1:<<<}long two long two long two long two l|
|
||||
ong two long two long two long two long |
|
||||
two long two long two long two long two |
|
||||
long two long two long two long two long|
|
||||
two long two long two long two long two|
|
||||
^ long two long two long two long two lon|
|
||||
g two long two long |
|
||||
:norm j721| |
|
||||
]])
|
||||
feed('gj')
|
||||
screen:expect([[
|
||||
{1:<<<}long two long two long two long two l|
|
||||
ong two long two long two long two long |
|
||||
two long two long two long two long two |
|
||||
long two long two long two long two long|
|
||||
two long two long two long two long two|
|
||||
long two long two long two long two lon|
|
||||
^g two long two long |
|
||||
:norm j721| |
|
||||
]])
|
||||
feed('gj')
|
||||
screen:expect([[
|
||||
{1:<<<} long two long two long two long two |
|
||||
long two long two long two long two long|
|
||||
two long two long two long two long two|
|
||||
long two long two long two long two lon|
|
||||
g two long two long |
|
||||
^three |
|
||||
four |
|
||||
:norm j721| |
|
||||
]])
|
||||
feed('gk')
|
||||
--FIXME: incorrect screen due to reset_skipcol()/curs_columns() shenanigans
|
||||
screen:expect([[
|
||||
two long two long two long two long two |
|
||||
long two long two long two long two long|
|
||||
two long two long two long two long two|
|
||||
long two long two long two long two lon|
|
||||
g two long two long two long two long tw|
|
||||
o long two long two long two long two lo|
|
||||
^ng two long two long two long two long t|
|
||||
:norm j721| |
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
|
@ -1156,4 +1156,39 @@ func Test_smoothscroll_long_line_zb()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_smooth_long_scrolloff()
|
||||
CheckScreendump
|
||||
|
||||
let lines =<< trim END
|
||||
set smoothscroll scrolloff=3
|
||||
call setline(1, ['one', 'two long '->repeat(100), 'three', 'four', 'five', 'six'])
|
||||
END
|
||||
call writefile(lines, 'XSmoothLongScrolloff', 'D')
|
||||
let buf = RunVimInTerminal('-u NONE -S XSmoothLongScrolloff', #{rows: 8, cols: 40})
|
||||
"FIXME: empty screen due to reset_skipcol()/curs_columns() shenanigans
|
||||
call term_sendkeys(buf, ":norm j721|\<CR>")
|
||||
call VerifyScreenDump(buf, 'Test_smooth_long_scrolloff_1', {})
|
||||
|
||||
call term_sendkeys(buf, "gj")
|
||||
call VerifyScreenDump(buf, 'Test_smooth_long_scrolloff_2', {})
|
||||
|
||||
call term_sendkeys(buf, "gj")
|
||||
call VerifyScreenDump(buf, 'Test_smooth_long_scrolloff_3', {})
|
||||
|
||||
call term_sendkeys(buf, "gj")
|
||||
call VerifyScreenDump(buf, 'Test_smooth_long_scrolloff_4', {})
|
||||
|
||||
call term_sendkeys(buf, "gj")
|
||||
call VerifyScreenDump(buf, 'Test_smooth_long_scrolloff_5', {})
|
||||
|
||||
call term_sendkeys(buf, "gj")
|
||||
call VerifyScreenDump(buf, 'Test_smooth_long_scrolloff_6', {})
|
||||
|
||||
call term_sendkeys(buf, "gk")
|
||||
"FIXME: empty screen due to reset_skipcol()/curs_columns() shenanigans
|
||||
call VerifyScreenDump(buf, 'Test_smooth_long_scrolloff_7', {})
|
||||
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Loading…
Reference in New Issue
Block a user