Skip to content

Commit 7746348

Browse files
phanenchrisbra
authored andcommitted
patch 9.1.1238: wrong cursor column with 'set splitkeep=screen'
Problem: With ':set splitkeep=screen', cursor did't restore column correctly when splitting a window on a line longer than the last line on the screen (after v9.1.0707) Solution: Restore cursor column in `win_fix_scroll()` since it may be changed in `getvcol()` after 396fd1e (phanium). Example: ``` echo longlonglongling\nshort | vim - -u NONE --cmd 'set splitkeep=screen' +'norm $' +new +q ``` fixes: #16968 closes: #16971 Signed-off-by: phanium <91544758+phanen@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 2726821 commit 7746348

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/testdir/test_window_cmd.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,6 +1979,18 @@ func Test_splitkeep_misc()
19791979
set splitkeep&
19801980
endfunc
19811981

1982+
func Test_splitkeep_screen_cursor_pos()
1983+
new
1984+
set splitkeep=screen
1985+
call setline(1, ["longer than the last", "shorter"])
1986+
norm! $
1987+
wincmd s
1988+
close
1989+
call assert_equal([0, 1, 20, 0], getpos('.'))
1990+
%bwipeout!
1991+
set splitkeep&
1992+
endfunc
1993+
19821994
func Test_splitkeep_cursor()
19831995
CheckScreendump
19841996
let lines =<< trim END

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+
1238,
707709
/**/
708710
1237,
709711
/**/

src/window.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7038,7 +7038,7 @@ win_fix_scroll(int resize)
70387038
{
70397039
int diff = (wp->w_winrow - wp->w_prev_winrow)
70407040
+ (wp->w_height - wp->w_prev_height);
7041-
linenr_T lnum = wp->w_cursor.lnum;
7041+
pos_T cursor = wp->w_cursor;
70427042
wp->w_cursor.lnum = wp->w_botline - 1;
70437043

70447044
// Add difference in height and row to botline.
@@ -7052,7 +7052,8 @@ win_fix_scroll(int resize)
70527052
wp->w_fraction = FRACTION_MULT;
70537053
scroll_to_fraction(wp, wp->w_prev_height);
70547054

7055-
wp->w_cursor.lnum = lnum;
7055+
wp->w_cursor = cursor;
7056+
wp->w_valid &= ~VALID_WCOL;
70567057
}
70577058
else if (wp == curwin)
70587059
wp->w_valid &= ~VALID_CROW;

0 commit comments

Comments
 (0)