0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 9.0.1512: inserting lines when scrolling with 'smoothscroll' set

Problem:    Inserting lines when scrolling with 'smoothscroll' set.
Solution:   Adjust line height computation for w_skipcol. (Luuk van Baal,
            closes #12350)
This commit is contained in:
Luuk van Baal
2023-05-06 12:40:15 +01:00
committed by Bram Moolenaar
parent 12e7a1fe75
commit c8502f9b88
6 changed files with 46 additions and 6 deletions

View File

@@ -2327,8 +2327,14 @@ win_update(win_T *wp)
{ {
#ifdef FEAT_DIFF #ifdef FEAT_DIFF
if (l == wp->w_topline) 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)
n = wp->w_height;
new_rows += n;
}
else else
#endif #endif
new_rows += plines_win(wp, l, TRUE); new_rows += plines_win(wp, l, TRUE);

View File

@@ -38,7 +38,7 @@ static void botline_forw(lineoff_T *lp);
/* /*
* Reduce "n" for the screen lines skipped with "wp->w_skipcol". * Reduce "n" for the screen lines skipped with "wp->w_skipcol".
*/ */
static int int
adjust_plines_for_skipcol(win_T *wp, int n) adjust_plines_for_skipcol(win_T *wp, int n)
{ {
if (wp->w_skipcol == 0) if (wp->w_skipcol == 0)
@@ -239,7 +239,7 @@ skipcol_from_plines(win_T *wp, int plines_off)
} }
/* /*
* Set curwin->s_skipcol to zero and redraw later if needed. * Set curwin->w_skipcol to zero and redraw later if needed.
*/ */
static void static void
reset_skipcol(void) reset_skipcol(void)
@@ -2990,7 +2990,7 @@ cursor_correct(void)
if (curwin->w_p_sms && !curwin->w_p_wrap) if (curwin->w_p_sms && !curwin->w_p_wrap)
{ {
// 'smoothscroll is active // 'smoothscroll' is active
if (curwin->w_cline_height == curwin->w_height) if (curwin->w_cline_height == curwin->w_height)
{ {
// The cursor line just fits in the window, don't scroll. // The cursor line just fits in the window, don't scroll.

View File

@@ -1,4 +1,5 @@
/* move.c */ /* move.c */
int adjust_plines_for_skipcol(win_T *wp, int n);
void redraw_for_cursorline(win_T *wp); void redraw_for_cursorline(win_T *wp);
void update_topline_redraw(void); void update_topline_redraw(void);
void update_topline(void); void update_topline(void);

View File

@@ -0,0 +1,6 @@
|<+0#4040ff13#ffffff0@2|l+0#0000000&|o|t|s| |o|f| |t|e|x|t| |i|n| |o|n|e| |l|i|n|e> @12
|l|i|n|e| |t|w|o| @31
|l|i|n|e| |t|h|r|e@1| @29
|l|i|n|e| |f|o|u|r| @30
|l|i|n|e| |f|i|v|e| @30
@22|1|,|6|8| @9|A|l@1|

View File

@@ -587,7 +587,7 @@ func Test_smoothscroll_mouse_pos()
endfunc endfunc
" this was dividing by zero " this was dividing by zero
func Test_smoothscrol_zero_width() func Test_smoothscroll_zero_width()
CheckScreendump CheckScreendump
let lines =<< trim END let lines =<< trim END
@@ -613,5 +613,30 @@ func Test_smoothscrol_zero_width()
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
endfunc 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 " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1512,
/**/ /**/
1511, 1511,
/**/ /**/