When restoring a session that has multiple tab pages, the current
window for each tab page is not restored as expected.  The new test
below currently fails but should pass:


diff --git a/src/testdir/test_mksession.vim b/src/testdir/test_mksession.vim
index bc41396..80bedfc 100644
--- a/src/testdir/test_mksession.vim
+++ b/src/testdir/test_mksession.vim
@@ -307,7 +307,6 @@ endfunc

 endif

-
 func Test_mksession_blank_windows()
   split
   split
@@ -323,6 +322,35 @@ func Test_mksession_blank_windows()
   call delete('Xtest_mks.out')
 endfunc

+func Test_mksession_tab_curwin()
+  only | tabonly
+
+  " tab with 2 windows
+  split
+  2 wincmd w
+  tabnew
+
+  " tab with 3 windows
+  split | split
+  3 wincmd w
+  tabnew
+
+  " tab with 4 windows
+  split | split | split
+  3 wincmd w
+  tabnew
+
+  mksession! Xtest_mks.out
+  source Xtest_mks.out
+  call assert_equal(2, tabpagewinnr(1))
+  call assert_equal(3, tabpagewinnr(2))
+  call assert_equal(3, tabpagewinnr(3))
+  call assert_equal(1, tabpagewinnr(4))
+  call delete('Xtest_mks.out')
+
+  %bw!
+endfunc
+
 if has('terminal')

 func Test_mksession_terminal_shell()


The patch below fixes the problem and cleans up some of the code a bit.


diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 16f5059..3c41b3d 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -9727,6 +9727,7 @@ makeopens(
     win_T      *edited_win = NULL;
     int                tabnr;
     int                restore_stal = FALSE;
+    win_T      *tab_curwin;
     win_T      *tab_firstwin;
     frame_T    *tab_topframe;
     int                cur_arg_idx = 0;
@@ -9842,7 +9843,8 @@ makeopens(
      * Don't use goto_tabpage(), it may change directory and trigger
      * autocommands.
      */
-    tab_firstwin = firstwin;   /* first window in tab page "tabnr" */
+    tab_curwin   = curwin;     // current window in tab page "tabnr"
+    tab_firstwin = firstwin;   // first window in tab page "tabnr"
     tab_topframe = topframe;
     if ((ssop_flags & SSOP_TABPAGES))
     {
@@ -9866,20 +9868,15 @@ makeopens(
        {
            tp = find_tabpage(tabnr);

+           // done all tab pages
            if (tp == NULL)
-               break;          /* done all tab pages */
-           if (tp == curtab)
-           {
-               tab_firstwin = firstwin;
-               tab_topframe = topframe;
-           }
-           else
-           {
-               tab_firstwin = tp->tp_firstwin;
-               tab_topframe = tp->tp_topframe;
-           }
-           if (tabnr > 1)
-               need_tabnext = TRUE;
+               break;
+
+           tab_curwin   = (tp == curtab) ? curwin   : tp->tp_curwin;
+           tab_firstwin = (tp == curtab) ? firstwin : tp->tp_firstwin;
+           tab_topframe = (tp == curtab) ? topframe : tp->tp_topframe;
+
+           need_tabnext = (tabnr > 1);
        }

        /*
@@ -9938,7 +9935,7 @@ makeopens(
                ++nr;
            else
                restore_size = FALSE;
-           if (curwin == wp)
+           if (tab_curwin == wp)
                cnr = nr;
        }


Thanks,
Jason Franklin

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/f35df5fb-12d3-4d52-997f-2cdb0b4809ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui