aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/move.c21
-rw-r--r--test/functional/legacy/scroll_opt_spec.lua29
-rw-r--r--test/old/testdir/test_scroll_opt.vim26
3 files changed, 66 insertions, 10 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 3b882a5d02..5e85768865 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -1094,8 +1094,9 @@ bool scrolldown(long line_count, int byfold)
int done = 0; // total # of physical lines done
int width1 = 0;
int width2 = 0;
+ bool do_sms = curwin->w_p_wrap && curwin->w_p_sms;
- if (curwin->w_p_wrap && curwin->w_p_sms) {
+ if (do_sms) {
width1 = curwin->w_width - curwin_col_off();
width2 = width1 + curwin_col_off2();
}
@@ -1103,17 +1104,17 @@ bool scrolldown(long line_count, int byfold)
// Make sure w_topline is at the first of a sequence of folded lines.
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
validate_cursor(); // w_wrow needs to be valid
- while (line_count-- > 0) {
+ for (long todo = line_count; todo > 0; todo--) {
if (curwin->w_topfill < win_get_fill(curwin, curwin->w_topline)
&& curwin->w_topfill < curwin->w_height_inner - 1) {
curwin->w_topfill++;
done++;
} else {
// break when at the very top
- if (curwin->w_topline == 1 && (!curwin->w_p_sms || curwin->w_skipcol < width1)) {
+ if (curwin->w_topline == 1 && (!do_sms || curwin->w_skipcol < width1)) {
break;
}
- if (curwin->w_p_wrap && curwin->w_p_sms && curwin->w_skipcol >= width1) {
+ if (do_sms && curwin->w_skipcol >= width1) {
// scroll a screen line down
if (curwin->w_skipcol >= width1 + width2) {
curwin->w_skipcol -= width2;
@@ -1132,12 +1133,12 @@ bool scrolldown(long line_count, int byfold)
if (hasFolding(curwin->w_topline, &first, NULL)) {
done++;
if (!byfold) {
- line_count -= curwin->w_topline - first - 1;
+ todo -= curwin->w_topline - first - 1;
}
curwin->w_botline -= curwin->w_topline - first;
curwin->w_topline = first;
} else {
- if (curwin->w_p_wrap && curwin->w_p_sms) {
+ if (do_sms) {
int size = (int)win_linetabsize(curwin, curwin->w_topline,
ml_get(curwin->w_topline), (colnr_T)MAXCOL);
if (size > width1) {
@@ -1209,15 +1210,15 @@ bool scrollup(long line_count, int byfold)
{
linenr_T topline = curwin->w_topline;
linenr_T botline = curwin->w_botline;
- int do_smoothscroll = curwin->w_p_wrap && curwin->w_p_sms;
+ int do_sms = curwin->w_p_wrap && curwin->w_p_sms;
- if (do_smoothscroll || (byfold && hasAnyFolding(curwin)) || win_may_fill(curwin)) {
+ if (do_sms || (byfold && hasAnyFolding(curwin)) || win_may_fill(curwin)) {
int width1 = curwin->w_width - curwin_col_off();
int width2 = width1 + curwin_col_off2();
int size = 0;
linenr_T prev_topline = curwin->w_topline;
- if (do_smoothscroll) {
+ if (do_sms) {
size = (int)win_linetabsize(curwin, curwin->w_topline,
ml_get(curwin->w_topline), (colnr_T)MAXCOL);
}
@@ -1261,7 +1262,7 @@ bool scrollup(long line_count, int byfold)
curwin->w_topline = lnum;
curwin->w_topfill = win_get_fill(curwin, lnum);
curwin->w_skipcol = 0;
- if (todo > 1 && do_smoothscroll) {
+ if (todo > 1 && do_sms) {
size = (int)win_linetabsize(curwin, curwin->w_topline,
ml_get(curwin->w_topline), (colnr_T)MAXCOL);
}
diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua
index 8d2eade1a8..90417d93f3 100644
--- a/test/functional/legacy/scroll_opt_spec.lua
+++ b/test/functional/legacy/scroll_opt_spec.lua
@@ -272,4 +272,33 @@ describe('smoothscroll', function()
|
]])
end)
+
+ -- oldtest: Test_smoothscroll_diff_mode()
+ it("works with diff mode", function()
+ screen:try_resize(40, 8)
+ exec([[
+ let text = 'just some text here'
+ call setline(1, text)
+ set smoothscroll
+ diffthis
+ new
+ call setline(1, text)
+ set smoothscroll
+ diffthis
+ ]])
+ screen:expect([[
+ - ^just some text here |
+ ~ |
+ ~ |
+ [No Name] [+] |
+ - just some text here |
+ ~ |
+ [No Name] [+] |
+ |
+ ]])
+ feed('<C-Y>')
+ screen:expect_unchanged()
+ feed('<C-E>')
+ screen:expect_unchanged()
+ end)
end)
diff --git a/test/old/testdir/test_scroll_opt.vim b/test/old/testdir/test_scroll_opt.vim
index f574286b09..53768de6fa 100644
--- a/test/old/testdir/test_scroll_opt.vim
+++ b/test/old/testdir/test_scroll_opt.vim
@@ -158,6 +158,32 @@ func Test_smoothscroll_number()
call StopVimInTerminal(buf)
endfunc
+func Test_smoothscroll_diff_mode()
+ CheckScreendump
+
+ let lines =<< trim END
+ vim9script
+ var text = 'just some text here'
+ setline(1, text)
+ set smoothscroll
+ diffthis
+ new
+ setline(1, text)
+ set smoothscroll
+ diffthis
+ END
+ call writefile(lines, 'XSmoothDiff', 'D')
+ let buf = RunVimInTerminal('-S XSmoothDiff', #{rows: 8})
+
+ call VerifyScreenDump(buf, 'Test_smooth_diff_1', {})
+ call term_sendkeys(buf, "\<C-Y>")
+ call VerifyScreenDump(buf, 'Test_smooth_diff_1', {})
+ call term_sendkeys(buf, "\<C-E>")
+ call VerifyScreenDump(buf, 'Test_smooth_diff_1', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab