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:
committed by
Bram Moolenaar
parent
12e7a1fe75
commit
c8502f9b88
@@ -2327,8 +2327,14 @@ win_update(win_T *wp)
|
||||
{
|
||||
#ifdef FEAT_DIFF
|
||||
if (l == wp->w_topline)
|
||||
new_rows += plines_win_nofill(wp, l, TRUE)
|
||||
{
|
||||
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
|
||||
#endif
|
||||
new_rows += plines_win(wp, l, TRUE);
|
||||
|
@@ -38,7 +38,7 @@ static void botline_forw(lineoff_T *lp);
|
||||
/*
|
||||
* Reduce "n" for the screen lines skipped with "wp->w_skipcol".
|
||||
*/
|
||||
static int
|
||||
int
|
||||
adjust_plines_for_skipcol(win_T *wp, int n)
|
||||
{
|
||||
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
|
||||
reset_skipcol(void)
|
||||
@@ -2990,7 +2990,7 @@ 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)
|
||||
{
|
||||
// The cursor line just fits in the window, don't scroll.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
/* move.c */
|
||||
int adjust_plines_for_skipcol(win_T *wp, int n);
|
||||
void redraw_for_cursorline(win_T *wp);
|
||||
void update_topline_redraw(void);
|
||||
void update_topline(void);
|
||||
|
6
src/testdir/dumps/Test_smooth_ins_lines.dump
Normal file
6
src/testdir/dumps/Test_smooth_ins_lines.dump
Normal 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|
|
@@ -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
|
||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1512,
|
||||
/**/
|
||||
1511,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user