Skip to content

Commit 5ed3917

Browse files
luukvbaalbrammool
authored andcommitted
patch 9.0.0455: a few problems with 'splitscroll'
Problem: A few problems with 'splitscroll'. Solution: Fix 'splitscroll' problems. (Luuk van Baal, closes #11117)
1 parent 810cb5a commit 5ed3917

5 files changed

Lines changed: 28 additions & 15 deletions

File tree

src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ main
375375
* Set the default values for the options that use Rows and Columns.
376376
*/
377377
ui_get_shellsize(); // inits Rows and Columns
378-
win_init_size();
379378
#ifdef FEAT_DIFF
380379
// Set the 'diff' option now, so that it can be checked for in a .vimrc
381380
// file. There is no buffer yet though.
@@ -542,6 +541,7 @@ vim_main2(void)
542541
mch_exit(1);
543542
}
544543
#endif
544+
win_init_size();
545545

546546
#ifdef FEAT_VIMINFO
547547
/*

src/menu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ ex_menu(
436436
--curwin->w_height;
437437
curwin->w_winbar_height = h;
438438
}
439+
curwin->w_prev_height = curwin->w_height;
439440
}
440441

441442
theend:

src/testdir/test_window_cmd.vim

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,7 @@ func Test_splitscroll_with_splits()
16461646
for so in [0, 5]
16471647
for ls in range(0, 2)
16481648
for pos in ["H", "M", "L"]
1649+
tabnew | tabonly! | redraw
16491650
let tabline = (gui ? 0 : (tab ? 1 : 0))
16501651
let winbar_sb = (sb ? winbar : 0)
16511652
execute 'set scrolloff=' . so
@@ -1655,17 +1656,23 @@ func Test_splitscroll_with_splits()
16551656
execute tab ? 'tabnew' : ''
16561657
execute winbar ? 'nnoremenu 1.10 WinBar.Test :echo' : ''
16571658
call setline(1, range(1, 256))
1659+
" No scroll for restore_snapshot
1660+
norm G
1661+
try
1662+
copen | close | colder
1663+
catch /E380/
1664+
endtry
1665+
call assert_equal(257 - winheight(0), line("w0"))
1666+
1667+
" No scroll for firstwin horizontal split
16581668
execute 'norm gg' . pos
1659-
" No scroll for vertical split and quit
1660-
vsplit | quit
1661-
call assert_equal(1, line("w0"))
1662-
1663-
" No scroll for horizontal split
1664-
split | redraw! | wincmd k
1669+
split | redraw | wincmd k
16651670
call assert_equal(1, line("w0"))
1671+
wincmd j
1672+
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
16661673

16671674
" No scroll when resizing windows
1668-
resize +2
1675+
wincmd k | resize +2
16691676
call assert_equal(1, line("w0"))
16701677
wincmd j
16711678
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
@@ -1715,7 +1722,7 @@ func Test_splitscroll_with_splits()
17151722
call assert_equal(1, line("w0"))
17161723

17171724
" No scroll in windows split and quit multiple times
1718-
quit | split | split | quit
1725+
quit | redraw | split | redraw | split | redraw | quit | redraw
17191726
call assert_equal(win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
17201727

17211728
" No scroll for new buffer
@@ -1740,11 +1747,9 @@ func Test_splitscroll_with_splits()
17401747
call assert_equal(6, line("w0"))
17411748
wincmd j
17421749
call assert_equal(5 + win_screenpos(0)[0] - tabline - winbar_sb, line("w0"))
1743-
only
17441750
endfor
17451751
endfor
17461752
endfor
1747-
tabonly!
17481753
endfor
17491754
endfor
17501755
endfor

src/version.c

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

704704
static int included_patches[] =
705705
{ /* Add new patch number below this line */
706+
/**/
707+
455,
706708
/**/
707709
454,
708710
/**/

src/window.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3923,6 +3923,7 @@ new_frame(win_T *wp)
39233923
win_init_size(void)
39243924
{
39253925
firstwin->w_height = ROWS_AVAIL;
3926+
firstwin->w_prev_height = ROWS_AVAIL;
39263927
topframe->fr_height = ROWS_AVAIL;
39273928
firstwin->w_width = Columns;
39283929
topframe->fr_width = Columns;
@@ -4069,6 +4070,7 @@ win_new_tabpage(int after)
40694070

40704071
win_init_size();
40714072
firstwin->w_winrow = tabline_height();
4073+
firstwin->w_prev_winrow = firstwin->w_winrow;
40724074
win_comp_scroll(curwin);
40734075

40744076
newtp->tp_topframe = topframe;
@@ -6372,10 +6374,8 @@ win_fix_scroll(int resize)
63726374
{
63736375
lnum = wp->w_cursor.lnum;
63746376
wp->w_cursor.lnum = MIN(wp->w_buffer->b_ml.ml_line_count,
6375-
wp->w_botline - 1 + (wp->w_prev_height
6376-
? (wp->w_winrow - wp->w_prev_winrow)
6377-
+ (wp->w_height - wp->w_prev_height)
6378-
: -WINBAR_HEIGHT(wp)));
6377+
wp->w_botline - 1 + (wp->w_winrow - wp->w_prev_winrow)
6378+
+ (wp->w_height - wp->w_prev_height));
63796379
// Bring the new cursor position to the bottom of the screen.
63806380
wp->w_fraction = FRACTION_MULT;
63816381
scroll_to_fraction(wp, wp->w_prev_height);
@@ -6802,6 +6802,9 @@ last_status_rec(frame_T *fr, int statusline)
68026802
comp_col();
68036803
redraw_all_later(UPD_SOME_VALID);
68046804
}
6805+
// Set prev_height when difference is due to 'laststatus'.
6806+
if (abs(wp->w_height - wp->w_prev_height) == 1)
6807+
wp->w_prev_height = wp->w_height;
68056808
}
68066809
else if (fr->fr_layout == FR_ROW)
68076810
{
@@ -7091,6 +7094,8 @@ restore_snapshot(
70917094
win_comp_pos();
70927095
if (wp != NULL && close_curwin)
70937096
win_goto(wp);
7097+
if (!p_spsc)
7098+
win_fix_scroll(FALSE);
70947099
redraw_all_later(UPD_NOT_VALID);
70957100
}
70967101
clear_snapshot(curtab, idx);

0 commit comments

Comments
 (0)