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();
(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)
{
// 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)
{
++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);
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
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);
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);
}
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