comparison src/window.c @ 31162:981f7bc781bb v9.0.0915

patch 9.0.0915: WinScrolled may trigger immediately when defined Commit: https://github.com/vim/vim/commit/29967732761d1ffb5592db5f5aa7036f5b52abf1 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Nov 20 12:11:45 2022 +0000 patch 9.0.0915: WinScrolled may trigger immediately when defined Problem: WinScrolled may trigger immediately when defined. Solution: Initialize the fields in all windows. (closes https://github.com/vim/vim/issues/11582)
author Bram Moolenaar <Bram@vim.org>
date Sun, 20 Nov 2022 13:15:04 +0100
parents 514ab6bdf73d
children a86ee6c0309e
comparison
equal deleted inserted replaced
31161:8444cb417799 31162:981f7bc781bb
2844 2844
2845 /* 2845 /*
2846 * Make a snapshot of all the window scroll positions and sizes of the current 2846 * Make a snapshot of all the window scroll positions and sizes of the current
2847 * tab page. 2847 * tab page.
2848 */ 2848 */
2849 static void 2849 void
2850 snapshot_windows_scroll_size(void) 2850 snapshot_windows_scroll_size(void)
2851 { 2851 {
2852 win_T *wp; 2852 win_T *wp;
2853 FOR_ALL_WINDOWS(wp) 2853 FOR_ALL_WINDOWS(wp)
2854 { 2854 {
3862 if (message && !ONE_WINDOW) 3862 if (message && !ONE_WINDOW)
3863 emsg(_(e_other_window_contains_changes)); 3863 emsg(_(e_other_window_contains_changes));
3864 } 3864 }
3865 3865
3866 /* 3866 /*
3867 * Store the relevant window pointers for tab page "tp". To be used before
3868 * use_tabpage().
3869 */
3870 void
3871 unuse_tabpage(tabpage_T *tp)
3872 {
3873 tp->tp_topframe = topframe;
3874 tp->tp_firstwin = firstwin;
3875 tp->tp_lastwin = lastwin;
3876 tp->tp_curwin = curwin;
3877 }
3878
3879 /*
3880 * Set the relevant pointers to use tab page "tp". May want to call
3881 * unuse_tabpage() first.
3882 */
3883 void
3884 use_tabpage(tabpage_T *tp)
3885 {
3886 curtab = tp;
3887 topframe = curtab->tp_topframe;
3888 firstwin = curtab->tp_firstwin;
3889 lastwin = curtab->tp_lastwin;
3890 curwin = curtab->tp_curwin;
3891 }
3892
3893 /*
3867 * Allocate the first window and put an empty buffer in it. 3894 * Allocate the first window and put an empty buffer in it.
3868 * Called from main(). 3895 * Called from main().
3869 * Return FAIL when something goes wrong (out of memory). 3896 * Return FAIL when something goes wrong (out of memory).
3870 */ 3897 */
3871 int 3898 int
3875 return FAIL; 3902 return FAIL;
3876 3903
3877 first_tabpage = alloc_tabpage(); 3904 first_tabpage = alloc_tabpage();
3878 if (first_tabpage == NULL) 3905 if (first_tabpage == NULL)
3879 return FAIL; 3906 return FAIL;
3880 first_tabpage->tp_topframe = topframe;
3881 curtab = first_tabpage; 3907 curtab = first_tabpage;
3882 curtab->tp_firstwin = firstwin; 3908 unuse_tabpage(first_tabpage);
3883 curtab->tp_lastwin = lastwin;
3884 curtab->tp_curwin = curwin;
3885 3909
3886 return OK; 3910 return OK;
3887 } 3911 }
3888 3912
3889 /* 3913 /*
4387 int row; 4411 int row;
4388 int old_off = tp->tp_firstwin->w_winrow; 4412 int old_off = tp->tp_firstwin->w_winrow;
4389 win_T *next_prevwin = tp->tp_prevwin; 4413 win_T *next_prevwin = tp->tp_prevwin;
4390 tabpage_T *last_tab = curtab; 4414 tabpage_T *last_tab = curtab;
4391 4415
4392 curtab = tp; 4416 use_tabpage(tp);
4393 firstwin = tp->tp_firstwin;
4394 lastwin = tp->tp_lastwin;
4395 topframe = tp->tp_topframe;
4396 4417
4397 // We would like doing the TabEnter event first, but we don't have a 4418 // We would like doing the TabEnter event first, but we don't have a
4398 // valid current window yet, which may break some commands. 4419 // valid current window yet, which may break some commands.
4399 // This triggers autocommands, thus may make "tp" invalid. 4420 // This triggers autocommands, thus may make "tp" invalid.
4400 (void)win_enter_ext(tp->tp_curwin, WEE_CURWIN_INVALID 4421 (void)win_enter_ext(tp->tp_curwin, WEE_CURWIN_INVALID