]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1472: ":drop fname" may change the last used tab page v9.0.1472
authorBram Moolenaar <Bram@vim.org>
Thu, 20 Apr 2023 17:07:57 +0000 (18:07 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 20 Apr 2023 17:07:57 +0000 (18:07 +0100)
Problem:    ":drop fname" may change the last used tab page.
Solution:   Restore the last used tab page when :drop has changed it.
            (closes #12087)

src/arglist.c
src/testdir/test_tabpage.vim
src/version.c

index bb31c45e93f4286d7a3394a01bbab5d455329f12..a63f6c72f8bc0a77e152eaea43b7751ef3211902 100644 (file)
@@ -1240,6 +1240,8 @@ do_arg_all(
     need_mouse_correct = TRUE;
 #endif
 
+    tabpage_T *new_lu_tp = curtab;
+
     // Try closing all windows that are not in the argument list.
     // Also close windows that are not full width;
     // When 'hidden' or "forceit" set the buffer becomes hidden.
@@ -1247,6 +1249,10 @@ do_arg_all(
     // When the ":tab" modifier was used do this for all tab pages.
     arg_all_close_unused_windows(&aall);
 
+    // Now set the last used tabpage to where we started.
+    if (valid_tabpage(new_lu_tp))
+       lastused_tabpage = new_lu_tp;
+
     // Open a window for files in the argument list that don't have one.
     // ARGCOUNT may change while doing this, because of autocommands.
     if (count > aall.opened_len || count <= 0)
index 83d6123cd7ef73391216613dbb00392229e4d4ab..eed26f72218143fc4106964674d4455389511532 100644 (file)
@@ -150,6 +150,22 @@ function Test_tabpage()
   tabonly!
 endfunc
 
+func Test_tabpage_drop()
+  edit f1
+  tab split f2
+  tab split f3
+  normal! gt
+  call assert_equal(1, tabpagenr())
+
+  tab drop f3
+  call assert_equal(3, tabpagenr())
+  call assert_equal(1, tabpagenr('#'))
+  bwipe!
+  bwipe!
+  bwipe!
+  call assert_equal(1, tabpagenr('$'))
+endfunc
+
 " Test autocommands
 function Test_tabpage_with_autocmd()
   command -nargs=1 -bar C :call add(s:li, '=== ' . <q-args> . ' ===')|<args>
index 99d1aecf66aebc5fa49448048277836f3ceea32c..611bd82ab2d75031e95920f351e5f4919d4144c0 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1472,
 /**/
     1471,
 /**/