Skip to content

Commit 13ece2a

Browse files
luukvbaalbrammool
authored andcommitted
patch 9.0.0647: the 'splitscroll' option is not a good name
Problem: The 'splitscroll' option is not a good name. Solution: Rename 'splitscroll' to 'splitkeep' and make it a string option, also supporting "topline". (Luuk van Baal, closes #11258)
1 parent 6b2d4ff commit 13ece2a

21 files changed

+142
-130
lines changed

runtime/doc/options.txt

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7518,24 +7518,28 @@ A jump table for the options with a short description can be found at |Q_op|.
75187518
When on, splitting a window will put the new window below the current
75197519
one. |:split|
75207520

7521+
*'splitkeep'* *'spk'
7522+
'splitkeep' 'spk' string (default "cursor")
7523+
global
7524+
The value of this option determines the scroll behavior when opening,
7525+
closing or resizing horizontal splits.
7526+
7527+
Possible values are:
7528+
cursor Keep the same relative cursor position.
7529+
screen Keep the text on the same screen line.
7530+
topline Keep the topline the same.
7531+
7532+
For the "screen" and "topline" values, the cursor position will be
7533+
changed when necessary. In this case, the jumplist will be populated
7534+
with the previous cursor position. For "screen", the text cannot always
7535+
be kept on the same screen line when 'wrap' is enabled.
7536+
75217537
*'splitright'* *'spr'* *'nosplitright'* *'nospr'*
75227538
'splitright' 'spr' boolean (default off)
75237539
global
75247540
When on, splitting a window will put the new window right of the
75257541
current one. |:vsplit|
75267542

7527-
*'splitscroll'* *'spsc'* *'nosplitscroll'* *'nospsc'*
7528-
'splitscroll' 'spsc' boolean (default on)
7529-
global
7530-
The value of this option determines the scroll behavior when opening,
7531-
closing or resizing horizontal splits. When "on", splitting a window
7532-
horizontally will keep the same relative cursor position in the old and
7533-
new window, as well windows that are resized. When "off", scrolling
7534-
will be avoided to stabilize the window content. Instead, the cursor
7535-
position will be changed when necessary. In this case, the jumplist
7536-
will be populated with the previous cursor position. Scrolling cannot
7537-
be guaranteed to be avoided when 'wrap' is enabled.
7538-
75397543
*'startofline'* *'sol'* *'nostartofline'* *'nosol'*
75407544
'startofline' 'sol' boolean (default on)
75417545
global

runtime/doc/quickref.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,8 @@ Short explanation of each option: *option-list*
919919
'spelloptions' 'spo' options for spell checking
920920
'spellsuggest' 'sps' method(s) used to suggest spelling corrections
921921
'splitbelow' 'sb' new window from split is below the current one
922+
'splitkeep' 'spk' determines scroll behavior for split windows
922923
'splitright' 'spr' new window is put right of the current one
923-
'splitscroll' 'spsc' determines scroll behavior for split windows
924924
'startofline' 'sol' commands move cursor to first non-blank in line
925925
'statusline' 'stl' custom format for the status line
926926
'suffixes' 'su' suffixes that are ignored with multiple match

runtime/optwin.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,10 +516,10 @@ call <SID>AddOption("switchbuf", gettext("\"useopen\" and/or \"split\"; which wi
516516
call <SID>OptionG("swb", &swb)
517517
call <SID>AddOption("splitbelow", gettext("a new window is put below the current one"))
518518
call <SID>BinOptionG("sb", &sb)
519+
call <SID>AddOption("splitkeep", gettext("determines scroll behavior for split windows"))
520+
call <SID>BinOptionG("spk", &spk)
519521
call <SID>AddOption("splitright", gettext("a new window is put right of the current one"))
520522
call <SID>BinOptionG("spr", &spr)
521-
call <SID>AddOption("splitscroll", gettext("determines scroll behavior for split windows"))
522-
call <SID>BinOptionG("spsc", &spsc)
523523
call <SID>AddOption("scrollbind", gettext("this window scrolls together with other bound windows"))
524524
call append("$", "\t" .. s:local_to_window)
525525
call <SID>BinOptionL("scb")

src/globals.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,10 +1975,10 @@ EXTERN int channel_need_redraw INIT(= FALSE);
19751975
EXTERN optmagic_T magic_overruled INIT(= OPTION_MAGIC_NOT_SET);
19761976

19771977
#ifdef FEAT_CMDWIN
1978-
// Skip win_fix_cursor() call for 'nosplitscroll' when cmdwin is closed.
1978+
// Skip win_fix_cursor() call for 'splitkeep' when cmdwin is closed.
19791979
EXTERN int skip_win_fix_cursor INIT(= FALSE);
19801980
#endif
1981-
// Skip win_fix_scroll() call for 'nosplitscroll' when closing tab page.
1981+
// Skip win_fix_scroll() call for 'splitkeep' when closing tab page.
19821982
EXTERN int skip_win_fix_scroll INIT(= FALSE);
19831983
// Skip update_topline() call while executing win_fix_scroll().
19841984
EXTERN int skip_update_topline INIT(= FALSE);

src/move.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ update_topline(void)
219219
long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so;
220220
int save_so = *so_ptr;
221221

222+
// Cursor is updated instead when this is TRUE for 'splitkeep'.
223+
if (skip_update_topline)
224+
return;
225+
222226
// If there is no valid screen and when the window height is zero just use
223227
// the cursor line.
224228
if (!screen_valid(TRUE) || curwin->w_height == 0)
@@ -1027,8 +1031,7 @@ curs_columns(
10271031
/*
10281032
* First make sure that w_topline is valid (after moving the cursor).
10291033
*/
1030-
if (!skip_update_topline)
1031-
update_topline();
1034+
update_topline();
10321035

10331036
/*
10341037
* Next make sure that w_cline_row is valid.

src/option.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,11 +924,11 @@ EXTERN char_u *p_spo; // 'spelloptions'
924924
EXTERN char_u *p_sps; // 'spellsuggest'
925925
#endif
926926
EXTERN int p_spr; // 'splitright'
927-
EXTERN int p_spsc; // 'splitscroll'
928927
EXTERN int p_sol; // 'startofline'
929928
EXTERN char_u *p_su; // 'suffixes'
930929
EXTERN char_u *p_sws; // 'swapsync'
931930
EXTERN char_u *p_swb; // 'switchbuf'
931+
EXTERN char_u *p_spk; // 'splitkeep'
932932
EXTERN unsigned swb_flags;
933933
// Keep in sync with p_swb_values in optionstr.c
934934
#define SWB_USEOPEN 0x001

src/optiondefs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,12 +2350,12 @@ static struct vimoption options[] =
23502350
{"splitbelow", "sb", P_BOOL|P_VI_DEF,
23512351
(char_u *)&p_sb, PV_NONE,
23522352
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
2353+
{"splitkeep", "spk", P_STRING,
2354+
(char_u *)&p_spk, PV_NONE,
2355+
{(char_u *)"cursor", (char_u *)"cursor"} SCTX_INIT},
23532356
{"splitright", "spr", P_BOOL|P_VI_DEF,
23542357
(char_u *)&p_spr, PV_NONE,
23552358
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
2356-
{"splitscroll", "spsc", P_BOOL,
2357-
(char_u *)&p_spsc, PV_NONE,
2358-
{(char_u *)TRUE, (char_u *)TRUE} SCTX_INIT},
23592359
{"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
23602360
(char_u *)&p_sol, PV_NONE,
23612361
{(char_u *)TRUE, (char_u *)0L} SCTX_INIT},

src/optionstr.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ static char *(p_ssop_values[]) = {"buffers", "winpos", "resize", "winsize",
4646
#endif
4747
// Keep in sync with SWB_ flags in option.h
4848
static char *(p_swb_values[]) = {"useopen", "usetab", "split", "newtab", "vsplit", "uselast", NULL};
49+
static char *(p_spk_values[]) = {"cursor", "screen", "topline", NULL};
4950
static char *(p_tc_values[]) = {"followic", "ignore", "match", "followscs", "smart", NULL};
5051
#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN)
5152
static char *(p_toolbar_values[]) = {"text", "icons", "tooltips", "horiz", NULL};
@@ -1683,6 +1684,13 @@ did_set_string_option(
16831684
errmsg = e_invalid_argument;
16841685
}
16851686

1687+
// 'splitkeep'
1688+
else if (varp == &p_spk)
1689+
{
1690+
if (check_opt_strings(p_spk, p_spk_values, FALSE) != OK)
1691+
errmsg = e_invalid_argument;
1692+
}
1693+
16861694
// 'debug'
16871695
else if (varp == &p_debug)
16881696
{
@@ -1722,7 +1730,7 @@ did_set_string_option(
17221730
int is_spellfile = varp == &(curwin->w_s->b_p_spf);
17231731

17241732
if ((is_spellfile && !valid_spellfile(*varp))
1725-
|| (!is_spellfile && !valid_spelllang(*varp)))
1733+
|| (!is_spellfile && !valid_spelllang(*varp)))
17261734
errmsg = e_invalid_argument;
17271735
else
17281736
errmsg = did_set_spell_option(is_spellfile);

src/structs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3621,8 +3621,8 @@ struct window_S
36213621
int w_winrow; // first row of window in screen
36223622
int w_height; // number of rows in window, excluding
36233623
// status/command/winbar line(s)
3624-
int w_prev_winrow; // previous winrow used for 'splitscroll'
3625-
int w_prev_height; // previous height used for 'splitscroll'
3624+
int w_prev_winrow; // previous winrow used for 'splitkeep'
3625+
int w_prev_height; // previous height used for 'splitkeep'
36263626

36273627
int w_status_height; // number of status lines (0 or 1)
36283628
int w_wincol; // Leftmost column of window in screen.
File renamed without changes.

0 commit comments

Comments
 (0)