mirror of
https://github.com/neovim/neovim.git
synced 2025-10-03 00:18:33 +00:00
vim-patch:8.2.2236: 'scroll' option can change when setting the statusline
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 vim/vim#7533)
746670604a
This commit is contained in:
@@ -3024,6 +3024,7 @@ void scriptnames_slash_adjust(void)
|
||||
# endif
|
||||
|
||||
/// Get a pointer to a script name. Used for ":verbose set".
|
||||
/// Message appended to "Last set from "
|
||||
char_u *get_scriptname(LastSet last_set, bool *should_free)
|
||||
{
|
||||
*should_free = false;
|
||||
@@ -3039,6 +3040,8 @@ char_u *get_scriptname(LastSet last_set, bool *should_free)
|
||||
return (char_u *)_("environment variable");
|
||||
case SID_ERROR:
|
||||
return (char_u *)_("error handler");
|
||||
case SID_WINLAYOUT:
|
||||
return (char_u *)_("changed window size");
|
||||
case SID_LUA:
|
||||
return (char_u *)_("Lua");
|
||||
case SID_API_CLIENT:
|
||||
|
@@ -333,9 +333,10 @@ EXTERN int garbage_collect_at_exit INIT(= false);
|
||||
#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_LUA -7 // for Lua scripts/chunks
|
||||
#define SID_API_CLIENT -8 // for API clients
|
||||
#define SID_STR -9 // for sourcing a string
|
||||
#define SID_WINLAYOUT -7 // changing window size
|
||||
#define SID_LUA -8 // for Lua scripts/chunks
|
||||
#define SID_API_CLIENT -9 // for API clients
|
||||
#define SID_STR -10 // for sourcing a string
|
||||
|
||||
// Script CTX being sourced or was sourced to define the current function.
|
||||
EXTERN sctx_T current_sctx INIT(= { 0 COMMA 0 COMMA 0 });
|
||||
|
@@ -636,4 +636,23 @@ func Test_isfname_with_options()
|
||||
setlocal keywordprg&
|
||||
endfunc
|
||||
|
||||
" Test that resetting laststatus does change scroll option
|
||||
func Test_opt_reset_scroll()
|
||||
" See test/functional/legacy/options_spec.lua
|
||||
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
|
||||
|
@@ -5960,9 +5960,17 @@ void win_new_width(win_T *wp, int width)
|
||||
|
||||
void win_comp_scroll(win_T *wp)
|
||||
{
|
||||
const long old_w_p_scr = wp->w_p_scr;
|
||||
|
||||
wp->w_p_scr = wp->w_height / 2;
|
||||
if (wp->w_p_scr == 0)
|
||||
if (wp->w_p_scr == 0) {
|
||||
wp->w_p_scr = 1;
|
||||
}
|
||||
if (wp->w_p_scr != old_w_p_scr) {
|
||||
// Used by "verbose set scroll".
|
||||
wp->w_p_script_ctx[WV_SCROLL].script_ctx.sc_sid = SID_WINLAYOUT;
|
||||
wp->w_p_script_ctx[WV_SCROLL].script_ctx.sc_lnum = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user