To: vim_dev@googlegroups.com Subject: Patch 8.2.2236 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.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) Files: runtime/doc/options.txt, src/scriptfile.c, src/testdir/test_options.vim, src/vim.h, src/window.c *** ../vim-8.2.2235/runtime/doc/options.txt 2020-10-26 21:05:23.901469148 +0100 --- runtime/doc/options.txt 2020-12-28 15:32:27.585384401 +0100 *************** *** 6315,6321 **** 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 be used as the new value for 'scroll'. Reset to half the window height with ":set scroll=0". --- 6321,6329 ---- 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. 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". *** ../vim-8.2.2235/src/scriptfile.c 2020-12-27 14:02:23.814275541 +0100 --- src/scriptfile.c 2020-12-28 15:32:27.585384401 +0100 *************** *** 1553,1558 **** --- 1553,1559 ---- /* * 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,1572 **** --- 1568,1575 ---- 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; } *** ../vim-8.2.2235/src/testdir/test_options.vim 2020-11-21 21:41:36.182011155 +0100 --- src/testdir/test_options.vim 2020-12-28 15:32:27.585384401 +0100 *************** *** 1013,1016 **** --- 1013,1034 ---- 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 *** ../vim-8.2.2235/src/vim.h 2020-12-22 21:19:35.293652280 +0100 --- src/vim.h 2020-12-28 15:32:27.585384401 +0100 *************** *** 1232,1237 **** --- 1232,1238 ---- #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. *** ../vim-8.2.2235/src/window.c 2020-11-16 20:47:27.627516302 +0100 --- src/window.c 2020-12-28 15:39:26.944031208 +0100 *************** *** 6325,6333 **** --- 6325,6345 ---- 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 } /* *** ../vim-8.2.2235/src/version.c 2020-12-28 15:07:42.133637924 +0100 --- src/version.c 2020-12-28 15:40:32.107684835 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2236, /**/ -- He who laughs last, thinks slowest. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///