summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-10-06 13:09:17 +0100
committerBram Moolenaar <Bram@vim.org>2022-10-06 13:09:17 +0100
commit1a58e1d97cfc72e501cbf63ad75f46f1bb4c8da2 (patch)
tree958cfa487a889da895185024f5deb04a972830f0
parentc9f5f73206272ccad0aa536854debc5f9781978a (diff)
downloadvim-git-9.0.0671.tar.gz
patch 9.0.0671: negative topline using CTRL-Y with 'smoothscroll' and 'diff'v9.0.0671
Problem: Negative topline using CTRL-Y with 'smoothscroll' and 'diff'. (Ernie Rael) Solution: Only use 'smoothscroll' when 'wrap' is set.
-rw-r--r--src/move.c22
-rw-r--r--src/testdir/dumps/Test_smooth_diff_1.dump8
-rw-r--r--src/testdir/test_scroll_opt.vim26
-rw-r--r--src/version.c2
4 files changed, 47 insertions, 11 deletions
diff --git a/src/move.c b/src/move.c
index fcb415a96..e79ed726e 100644
--- a/src/move.c
+++ b/src/move.c
@@ -1458,10 +1458,11 @@ scrolldown(
long done = 0; // total # of physical lines done
int wrow;
int moved = FALSE;
+ int do_sms = curwin->w_p_wrap && curwin->w_p_sms;
int width1 = 0;
int width2 = 0;
- if (curwin->w_p_wrap && curwin->w_p_sms)
+ if (do_sms)
{
width1 = curwin->w_width - curwin_col_off();
width2 = width1 + curwin_col_off2();
@@ -1474,7 +1475,7 @@ scrolldown(
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
#endif
validate_cursor(); // w_wrow needs to be valid
- while (line_count-- > 0)
+ for (int todo = line_count; todo > 0; --todo)
{
#ifdef FEAT_DIFF
if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)
@@ -1488,10 +1489,9 @@ scrolldown(
{
// break when at the very top
if (curwin->w_topline == 1
- && (!curwin->w_p_sms || curwin->w_skipcol < width1))
+ && (!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)
@@ -1515,13 +1515,13 @@ scrolldown(
{
++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
#endif
- if (curwin->w_p_wrap && curwin->w_p_sms)
+ if (do_sms)
{
int size = win_linetabsize(curwin, curwin->w_topline,
ml_get(curwin->w_topline), (colnr_T)MAXCOL);
@@ -1602,9 +1602,9 @@ scrollup(
long line_count,
int byfold UNUSED) // TRUE: count a closed fold as one line
{
- 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
+ if (do_sms
# ifdef FEAT_FOLDING
|| (byfold && hasAnyFolding(curwin))
# endif
@@ -1618,7 +1618,7 @@ scrollup(
int size = 0;
linenr_T prev_topline = curwin->w_topline;
- if (do_smoothscroll)
+ if (do_sms)
size = win_linetabsize(curwin, curwin->w_topline,
ml_get(curwin->w_topline), (colnr_T)MAXCOL);
@@ -1675,7 +1675,7 @@ scrollup(
curwin->w_topfill = diff_check_fill(curwin, lnum);
# endif
curwin->w_skipcol = 0;
- if (todo > 1 && do_smoothscroll)
+ if (todo > 1 && do_sms)
size = win_linetabsize(curwin, curwin->w_topline,
ml_get(curwin->w_topline), (colnr_T)MAXCOL);
}
diff --git a/src/testdir/dumps/Test_smooth_diff_1.dump b/src/testdir/dumps/Test_smooth_diff_1.dump
new file mode 100644
index 000000000..4e2696e84
--- /dev/null
+++ b/src/testdir/dumps/Test_smooth_diff_1.dump
@@ -0,0 +1,8 @@
+|-+0#0000e05#a8a8a8255| >j+0#0000000#ffffff0|u|s|t| |s|o|m|e| |t|e|x|t| |h|e|r|e| @53
+|~+0#4040ff13&| @73
+|~| @73
+|[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|1| @11|A|l@1
+|-+0#0000e05#a8a8a8255| |j+0#0000000#ffffff0|u|s|t| |s|o|m|e| |t|e|x|t| |h|e|r|e| @53
+|~+0#4040ff13&| @73
+|[+1#0000000&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|1| @11|A|l@1
+| +0&&@74
diff --git a/src/testdir/test_scroll_opt.vim b/src/testdir/test_scroll_opt.vim
index 5dfc69762..b114fe360 100644
--- a/src/testdir/test_scroll_opt.vim
+++ b/src/testdir/test_scroll_opt.vim
@@ -141,6 +141,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
diff --git a/src/version.c b/src/version.c
index a52b70791..5ddf40bab 100644
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 671,
+/**/
670,
/**/
669,