aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2023-04-26 17:08:35 +0200
committerLuuk van Baal <luukvbaal@gmail.com>2023-05-02 13:11:46 +0200
commit3a1973debceca29e65c4f7c83d025cb3314ebaf2 (patch)
tree9e95232ac61fcf9dda8389526a50165234d8e431
parent8e4a4629cab3377ba6fd5e291cf5f17fb4ff8a5c (diff)
downloadrneovim-3a1973debceca29e65c4f7c83d025cb3314ebaf2.tar.gz
rneovim-3a1973debceca29e65c4f7c83d025cb3314ebaf2.tar.bz2
rneovim-3a1973debceca29e65c4f7c83d025cb3314ebaf2.zip
vim-patch:9.0.0672: line partly shows with 'smoothscroll' and 'scrolloff' zero
Problem: Cursor line only partly shows with 'smoothscroll' and 'scrolloff' zero. Solution: Do not use 'smoothscroll' when adjusting the bottom of the window. (closes vim/vim#11269) https://github.com/vim/vim/commit/9bab7a024393200bb2c03b3abddfda86436990a7 Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r--src/nvim/move.c11
-rw-r--r--test/functional/legacy/scroll_opt_spec.lua26
-rw-r--r--test/old/testdir/test_scroll_opt.vim25
3 files changed, 62 insertions, 0 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 5e85768865..0a91b12255 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -1627,6 +1627,7 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
{
int used;
int scrolled = 0;
+ int min_scrolled = 1;
int extra = 0;
lineoff_T loff;
lineoff_T boff;
@@ -1676,6 +1677,12 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
if (cln == curwin->w_botline) {
scrolled -= curwin->w_empty_rows;
}
+ min_scrolled = scrolled;
+ if (cln > curwin->w_botline && curwin->w_p_sms && curwin->w_p_wrap) {
+ for (linenr_T lnum = curwin->w_botline + 1; lnum <= cln; lnum++) {
+ min_scrolled += plines_win_nofill(curwin, lnum, true);
+ }
+ }
}
// Stop counting lines to scroll when
@@ -1777,6 +1784,10 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
if (line_count >= curwin->w_height_inner && line_count > min_scroll) {
scroll_cursor_halfway(false, true);
} else {
+ // With 'smoothscroll' scroll at least the height of the cursor line.
+ if (curwin->w_p_wrap && curwin->w_p_sms && line_count < min_scrolled) {
+ line_count = min_scrolled;
+ }
scrollup(line_count, true);
}
diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua
index 90417d93f3..c63401cb02 100644
--- a/test/functional/legacy/scroll_opt_spec.lua
+++ b/test/functional/legacy/scroll_opt_spec.lua
@@ -301,4 +301,30 @@ describe('smoothscroll', function()
feed('<C-E>')
screen:expect_unchanged()
end)
+
+ -- oldtest: Test_smoothscroll_wrap_scrolloff_zero()
+ it("works with zero 'scrolloff'", function()
+ screen:try_resize(40, 8)
+ exec([[
+ call setline(1, ['Line' .. (' with some text'->repeat(7))]->repeat(7))
+ set smoothscroll scrolloff=0
+ :3
+ ]])
+ screen:expect([[
+ <<<h some text with some text |
+ Line with some text with some text with |
+ some text with some text with some text |
+ with some text with some text |
+ ^Line with some text with some text with |
+ some text with some text with some text |
+ with some text with some text |
+ |
+ ]])
+ feed('j')
+ screen:expect_unchanged()
+ feed('<C-E>j')
+ screen:expect_unchanged()
+ feed('G')
+ screen:expect_unchanged()
+ end)
end)
diff --git a/test/old/testdir/test_scroll_opt.vim b/test/old/testdir/test_scroll_opt.vim
index 53768de6fa..799db19298 100644
--- a/test/old/testdir/test_scroll_opt.vim
+++ b/test/old/testdir/test_scroll_opt.vim
@@ -184,6 +184,31 @@ func Test_smoothscroll_diff_mode()
call StopVimInTerminal(buf)
endfunc
+func Test_smoothscroll_wrap_scrolloff_zero()
+ CheckScreendump
+
+ let lines =<< trim END
+ vim9script
+ setline(1, ['Line' .. (' with some text'->repeat(7))]->repeat(7))
+ set smoothscroll scrolloff=0
+ :3
+ END
+ call writefile(lines, 'XSmoothWrap', 'D')
+ let buf = RunVimInTerminal('-S XSmoothWrap', #{rows: 8, cols: 40})
+
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_1', {})
+
+ call term_sendkeys(buf, "j")
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_2', {})
+
+ call term_sendkeys(buf, "\<C-E>j")
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_3', {})
+
+ call term_sendkeys(buf, "G")
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_4', {})
+
+ call StopVimInTerminal(buf)
+endfunc
" vim: shiftwidth=2 sts=2 expandtab