Skip to content

Commit 1bf1bf5

Browse files
luukvbaalchrisbra
authored andcommitted
patch 9.0.2081: smoothscroll may result in wrong cursor position
Problem: With 'smoothscroll' set, "w_skipcol" is not reset when unsetting 'wrap'. Resulting in incorrect calculation of the cursor position. Solution: Reset "w_skipcol" when unsetting 'wrap'. fixes: #12970 closes: #13439 Signed-off-by: Luuk van Baal <luukvbaal@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent a390e98 commit 1bf1bf5

3 files changed

Lines changed: 24 additions & 5 deletions

File tree

src/option.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4081,11 +4081,9 @@ did_set_showtabline(optset_T *args UNUSED)
40814081
char *
40824082
did_set_smoothscroll(optset_T *args UNUSED)
40834083
{
4084-
if (curwin->w_p_sms)
4085-
return NULL;
4084+
if (!curwin->w_p_sms)
4085+
curwin->w_skipcol = 0;
40864086

4087-
curwin->w_skipcol = 0;
4088-
changed_line_abv_curs();
40894087
return NULL;
40904088
}
40914089

@@ -4535,9 +4533,12 @@ did_set_winwidth(optset_T *args UNUSED)
45354533
char *
45364534
did_set_wrap(optset_T *args UNUSED)
45374535
{
4538-
// If 'wrap' is set, set w_leftcol to zero.
4536+
// Set w_leftcol or w_skipcol to zero.
45394537
if (curwin->w_p_wrap)
45404538
curwin->w_leftcol = 0;
4539+
else
4540+
curwin->w_skipcol = 0;
4541+
45414542
return NULL;
45424543
}
45434544

src/testdir/test_options.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,4 +2207,20 @@ func Test_set_keyprotocol()
22072207
let &term = term
22082208
endfunc
22092209

2210+
func Test_set_wrap()
2211+
" Unsetting 'wrap' when 'smoothscroll' is set does not result in incorrect
2212+
" cursor position.
2213+
set wrap smoothscroll scrolloff=5
2214+
2215+
call setline(1, ['', 'aaaa'->repeat(500)])
2216+
20 split
2217+
20 vsplit
2218+
norm 2G$
2219+
redraw
2220+
set nowrap
2221+
call assert_equal(2, winline())
2222+
2223+
set wrap& smoothscroll& scrolloff&
2224+
endfunc
2225+
22102226
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
2081,
707709
/**/
708710
2080,
709711
/**/

0 commit comments

Comments
 (0)