summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-12-28 15:41:41 +0100
committerBram Moolenaar <Bram@vim.org>2020-12-28 15:41:41 +0100
commit746670604a60cb0356b56c112ffb6d297c679099 (patch)
treebf0cdf7021500f0e39af0a7edb9d22dcc4bb9849
parentdace9f785fca6cc802b2fb7f11a5ee4fab896432 (diff)
downloadvim-git-746670604a60cb0356b56c112ffb6d297c679099.tar.gz
patch 8.2.2236: 'scroll' option can change when setting the statuslinev8.2.2236
Problem: 'scroll' option can change when setting the statusline or tabline but the option context is not updated. Solution: Update the script context when the scroll option is changed as a side effect. (Christian Brabandt, closes #7533)
-rw-r--r--runtime/doc/options.txt4
-rw-r--r--src/scriptfile.c3
-rw-r--r--src/testdir/test_options.vim18
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h1
-rw-r--r--src/window.c12
6 files changed, 39 insertions, 1 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index db62f8a34..4d26df86e 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -6321,7 +6321,9 @@ A jump table for the options with a short description can be found at |Q_op|.
local to window
Number of lines to scroll with CTRL-U and CTRL-D commands. Will be
set to half the number of lines in the window when the window size
- changes. If you give a count to the CTRL-U or CTRL-D command it will
+ changes. This may happen when enabling the |status-line| or
+ 'tabline' option after setting the 'scroll' option.
+ If you give a count to the CTRL-U or CTRL-D command it will
be used as the new value for 'scroll'. Reset to half the window
height with ":set scroll=0".
diff --git a/src/scriptfile.c b/src/scriptfile.c
index 90d483b9e..a9b382590 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -1553,6 +1553,7 @@ scriptnames_slash_adjust(void)
/*
* Get a pointer to a script name. Used for ":verbose set".
+ * Message appended to "Last set from "
*/
char_u *
get_scriptname(scid_T id)
@@ -1567,6 +1568,8 @@ get_scriptname(scid_T id)
return (char_u *)_("environment variable");
if (id == SID_ERROR)
return (char_u *)_("error handler");
+ if (id == SID_WINLAYOUT)
+ return (char_u *)_("changed window size");
return SCRIPT_ITEM(id)->sn_name;
}
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index 74f8d4c55..281c20c1f 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -1013,4 +1013,22 @@ func Test_isfname_with_options()
setlocal keywordprg&
endfunc
+" Test that resetting laststatus does change scroll option
+func Test_opt_reset_scroll()
+ CheckRunVimInTerminal
+ let vimrc =<< trim [CODE]
+ set scroll=2
+ set laststatus=2
+ [CODE]
+ call writefile(vimrc, 'Xscroll')
+ let buf = RunVimInTerminal('-S Xscroll', {'rows': 16, 'cols': 45})
+ call term_sendkeys(buf, ":verbose set scroll?\n")
+ call WaitForAssert({-> assert_match('Last set.*window size', term_getline(buf, 15))})
+ call assert_match('^\s*scroll=7$', term_getline(buf, 14))
+ call StopVimInTerminal(buf)
+
+ " clean up
+ call delete('Xscroll')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index f6c1bf237..401bce967 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2236,
+/**/
2235,
/**/
2234,
diff --git a/src/vim.h b/src/vim.h
index 1dedd8141..f19a4fe97 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -1232,6 +1232,7 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
#define SID_ENV -4 // for sourcing environment variable
#define SID_ERROR -5 // option was reset because of an error
#define SID_NONE -6 // don't set scriptID
+#define SID_WINLAYOUT -7 // changing window size
/*
* Events for autocommands.
diff --git a/src/window.c b/src/window.c
index 1134d0a6c..1cf795fd7 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6325,9 +6325,21 @@ win_new_width(win_T *wp, int width)
void
win_comp_scroll(win_T *wp)
{
+#if defined(FEAT_EVAL)
+ int old_w_p_scr = wp->w_p_scr;
+#endif
+
wp->w_p_scr = ((unsigned)wp->w_height >> 1);
if (wp->w_p_scr == 0)
wp->w_p_scr = 1;
+#if defined(FEAT_EVAL)
+ if (wp->w_p_scr != old_w_p_scr)
+ {
+ // Used by "verbose set scroll".
+ wp->w_p_script_ctx[WV_SCROLL].sc_sid = SID_WINLAYOUT;
+ wp->w_p_script_ctx[WV_SCROLL].sc_lnum = 0;
+ }
+#endif
}
/*