forked from aniani/vim
patch 9.0.0673: first line wong with 'smoothscroll' and 'scrolloff' zero
Problem: First line not scrolled properly with 'smoothscroll' and 'scrolloff' zero and using "k". Solution: Make sure the cursor position is visible.
This commit is contained in:
20
src/move.c
20
src/move.c
@@ -266,7 +266,7 @@ update_topline(void)
|
|||||||
*/
|
*/
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (curwin->w_topline > 1)
|
if (curwin->w_topline > 1 || curwin->w_skipcol > 0)
|
||||||
{
|
{
|
||||||
// If the cursor is above topline, scrolling is always needed.
|
// If the cursor is above topline, scrolling is always needed.
|
||||||
// If the cursor is far below topline and there is no folding,
|
// If the cursor is far below topline and there is no folding,
|
||||||
@@ -275,6 +275,16 @@ update_topline(void)
|
|||||||
check_topline = TRUE;
|
check_topline = TRUE;
|
||||||
else if (check_top_offset())
|
else if (check_top_offset())
|
||||||
check_topline = TRUE;
|
check_topline = TRUE;
|
||||||
|
else if (curwin->w_cursor.lnum == curwin->w_topline)
|
||||||
|
{
|
||||||
|
colnr_T vcol;
|
||||||
|
|
||||||
|
// check the cursor position is visible. Add 3 for the ">>>"
|
||||||
|
// displayed in the top-left.
|
||||||
|
getvvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL);
|
||||||
|
if (curwin->w_skipcol + 3 >= vcol)
|
||||||
|
check_topline = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
// Check if there are more filler lines than allowed.
|
// Check if there are more filler lines than allowed.
|
||||||
@@ -2007,6 +2017,7 @@ scroll_cursor_top(int min_scroll, int always)
|
|||||||
linenr_T top; // just above displayed lines
|
linenr_T top; // just above displayed lines
|
||||||
linenr_T bot; // just below displayed lines
|
linenr_T bot; // just below displayed lines
|
||||||
linenr_T old_topline = curwin->w_topline;
|
linenr_T old_topline = curwin->w_topline;
|
||||||
|
int old_skipcol = curwin->w_skipcol;
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
linenr_T old_topfill = curwin->w_topfill;
|
linenr_T old_topfill = curwin->w_topfill;
|
||||||
#endif
|
#endif
|
||||||
@@ -2118,7 +2129,14 @@ scroll_cursor_top(int min_scroll, int always)
|
|||||||
}
|
}
|
||||||
check_topfill(curwin, FALSE);
|
check_topfill(curwin, FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
// TODO: if the line doesn't fit may optimize w_skipcol
|
||||||
|
if (curwin->w_topline == curwin->w_cursor.lnum)
|
||||||
|
{
|
||||||
|
curwin->w_skipcol = 0;
|
||||||
|
redraw_later(UPD_NOT_VALID);
|
||||||
|
}
|
||||||
if (curwin->w_topline != old_topline
|
if (curwin->w_topline != old_topline
|
||||||
|
|| curwin->w_skipcol != old_skipcol
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
|| curwin->w_topfill != old_topfill
|
|| curwin->w_topfill != old_topfill
|
||||||
#endif
|
#endif
|
||||||
|
8
src/testdir/dumps/Test_smooth_wrap_5.dump
Normal file
8
src/testdir/dumps/Test_smooth_wrap_5.dump
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
>L+0&#ffffff0|i|n|e| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h|
|
||||||
|
|s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t|
|
||||||
|
|w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
|
||||||
|
|L|i|n|e| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h|
|
||||||
|
|s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t|
|
||||||
|
|w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
|
||||||
|
|@+0#4040ff13&@2| @36
|
||||||
|
| +0#0000000&@21|5|,|1| @10|8|0|%|
|
@@ -181,6 +181,7 @@ func Test_smoothscroll_wrap_scrolloff_zero()
|
|||||||
|
|
||||||
call VerifyScreenDump(buf, 'Test_smooth_wrap_1', {})
|
call VerifyScreenDump(buf, 'Test_smooth_wrap_1', {})
|
||||||
|
|
||||||
|
" moving cursor down - whole bottom line shows
|
||||||
call term_sendkeys(buf, "j")
|
call term_sendkeys(buf, "j")
|
||||||
call VerifyScreenDump(buf, 'Test_smooth_wrap_2', {})
|
call VerifyScreenDump(buf, 'Test_smooth_wrap_2', {})
|
||||||
|
|
||||||
@@ -190,6 +191,10 @@ func Test_smoothscroll_wrap_scrolloff_zero()
|
|||||||
call term_sendkeys(buf, "G")
|
call term_sendkeys(buf, "G")
|
||||||
call VerifyScreenDump(buf, 'Test_smooth_wrap_4', {})
|
call VerifyScreenDump(buf, 'Test_smooth_wrap_4', {})
|
||||||
|
|
||||||
|
" moving cursor up - whole top line shows
|
||||||
|
call term_sendkeys(buf, "2k")
|
||||||
|
call VerifyScreenDump(buf, 'Test_smooth_wrap_5', {})
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@@ -699,6 +699,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 */
|
||||||
|
/**/
|
||||||
|
673,
|
||||||
/**/
|
/**/
|
||||||
672,
|
672,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user