@@ -2846,7 +2846,7 @@ trigger_winclosed(win_T *win)
28462846 * Make a snapshot of all the window scroll positions and sizes of the current
28472847 * tab page.
28482848 */
2849- static void
2849+ void
28502850snapshot_windows_scroll_size (void )
28512851{
28522852 win_T * wp ;
@@ -3863,6 +3863,33 @@ close_others(
38633863 emsg (_ (e_other_window_contains_changes ));
38643864}
38653865
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+
38663893/*
38673894 * Allocate the first window and put an empty buffer in it.
38683895 * Called from main().
@@ -3877,11 +3904,8 @@ win_alloc_first(void)
38773904 first_tabpage = alloc_tabpage ();
38783905 if (first_tabpage == NULL )
38793906 return FAIL ;
3880- first_tabpage -> tp_topframe = topframe ;
38813907 curtab = first_tabpage ;
3882- curtab -> tp_firstwin = firstwin ;
3883- curtab -> tp_lastwin = lastwin ;
3884- curtab -> tp_curwin = curwin ;
3908+ unuse_tabpage (first_tabpage );
38853909
38863910 return OK ;
38873911}
@@ -4389,10 +4413,7 @@ enter_tabpage(
43894413 win_T * next_prevwin = tp -> tp_prevwin ;
43904414 tabpage_T * last_tab = curtab ;
43914415
4392- curtab = tp ;
4393- firstwin = tp -> tp_firstwin ;
4394- lastwin = tp -> tp_lastwin ;
4395- topframe = tp -> tp_topframe ;
4416+ use_tabpage (tp );
43964417
43974418 // We would like doing the TabEnter event first, but we don't have a
43984419 // valid current window yet, which may break some commands.
0 commit comments