diff options
-rw-r--r-- | src/nvim/drawscreen.c | 7 | ||||
-rw-r--r-- | src/nvim/move.c | 6 | ||||
-rw-r--r-- | test/functional/legacy/scroll_opt_spec.lua | 24 | ||||
-rw-r--r-- | test/old/testdir/test_scroll_opt.vim | 27 |
4 files changed, 59 insertions, 5 deletions
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index ec5163f37a..7f7c721379 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -2101,7 +2101,12 @@ static void win_update(win_T *wp, DecorProviders *providers) if (hasFoldingWin(wp, l, NULL, &l, true, NULL)) { new_rows++; } else if (l == wp->w_topline) { - new_rows += plines_win_nofill(wp, l, true) + wp->w_topfill; + int n = plines_win_nofill(wp, l, false) + wp->w_topfill; + n = adjust_plines_for_skipcol(wp, n); + if (n > wp->w_height_inner) { + n = wp->w_height_inner; + } + new_rows += n; } else { new_rows += plines_win(wp, l, true); } diff --git a/src/nvim/move.c b/src/nvim/move.c index c93c94f8c5..e09a95af70 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -58,7 +58,7 @@ typedef struct { #endif /// Reduce "n" for the screen lines skipped with "wp->w_skipcol". -static int adjust_plines_for_skipcol(win_T *wp, int n) +int adjust_plines_for_skipcol(win_T *wp, int n) { if (wp->w_skipcol == 0) { return n; @@ -196,7 +196,7 @@ static int skipcol_from_plines(win_T *wp, int plines_off) return skipcol; } -/// Set wp->s_skipcol to zero and redraw later if needed. +/// Set wp->w_skipcol to zero and redraw later if needed. static void reset_skipcol(win_T *wp) { if (wp->w_skipcol != 0) { @@ -2267,7 +2267,7 @@ void cursor_correct(void) } if (curwin->w_p_sms && !curwin->w_p_wrap) { - // 'smoothscroll is active + // 'smoothscroll' is active if (curwin->w_cline_height == curwin->w_height_inner) { // The cursor line just fits in the window, don't scroll. reset_skipcol(curwin); diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua index 8af23d2c26..c3c99b506b 100644 --- a/test/functional/legacy/scroll_opt_spec.lua +++ b/test/functional/legacy/scroll_opt_spec.lua @@ -695,6 +695,30 @@ describe('smoothscroll', function() ]]) end) + -- oldtest: Test_smoothscroll_ins_lines() + it("this was unnecessarily inserting lines", function() + screen:try_resize(40, 6) + exec([=[ + set wrap smoothscroll scrolloff=0 conceallevel=2 concealcursor=nc + call setline(1, [ + \'line one' .. 'with lots of text in one line '->repeat(2), + \'line two', + \'line three', + \'line four', + \'line five' + \]) + ]=]) + feed('<C-E>gjgk') + screen:expect([[ + <<<lots of text in one line^ | + line two | + line three | + line four | + line five | + | + ]]) + end) + it("works with virt_lines above and below", function() screen:try_resize(55, 7) exec([=[ diff --git a/test/old/testdir/test_scroll_opt.vim b/test/old/testdir/test_scroll_opt.vim index 8402fa51e2..e8c4c71b60 100644 --- a/test/old/testdir/test_scroll_opt.vim +++ b/test/old/testdir/test_scroll_opt.vim @@ -587,7 +587,7 @@ func Test_smoothscroll_mouse_pos() endfunc " this was dividing by zero -func Test_smoothscrol_zero_width() +func Test_smoothscroll_zero_width() CheckScreendump let lines =<< trim END @@ -613,5 +613,30 @@ func Test_smoothscrol_zero_width() call StopVimInTerminal(buf) endfunc +" this was unnecessarily inserting lines +func Test_smoothscroll_ins_lines() + CheckScreendump + + let lines =<< trim END + set wrap + set smoothscroll + set scrolloff=0 + set conceallevel=2 + call setline(1, [ + \'line one' .. 'with lots of text in one line '->repeat(2), + \'line two', + \'line three', + \'line four', + \'line five' + \]) + END + call writefile(lines, 'XSmoothScrollInsLines', 'D') + let buf = RunVimInTerminal('-S XSmoothScrollInsLines', #{rows: 6, cols: 40}) + + call term_sendkeys(buf, "\<C-E>gjgk") + call VerifyScreenDump(buf, 'Test_smooth_ins_lines', {}) + + call StopVimInTerminal(buf) +endfunc " vim: shiftwidth=2 sts=2 expandtab |