mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-patch:9.0.1472: ":drop fname" may change the last used tab page (#23230)
Problem: ":drop fname" may change the last used tab page.
Solution: Restore the last used tab page when :drop has changed it.
(closes vim/vim#12087)
8281a16efc
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -1071,6 +1071,8 @@ static void do_arg_all(int count, int forceit, int keep_tabs)
|
|||||||
aall.alist->al_refcount++;
|
aall.alist->al_refcount++;
|
||||||
arglist_locked = true;
|
arglist_locked = true;
|
||||||
|
|
||||||
|
tabpage_T *const new_lu_tp = curtab;
|
||||||
|
|
||||||
// Try closing all windows that are not in the argument list.
|
// Try closing all windows that are not in the argument list.
|
||||||
// Also close windows that are not full width;
|
// Also close windows that are not full width;
|
||||||
// When 'hidden' or "forceit" set the buffer becomes hidden.
|
// When 'hidden' or "forceit" set the buffer becomes hidden.
|
||||||
@@ -1078,6 +1080,11 @@ static void do_arg_all(int count, int forceit, int keep_tabs)
|
|||||||
// When the ":tab" modifier was used do this for all tab pages.
|
// When the ":tab" modifier was used do this for all tab pages.
|
||||||
arg_all_close_unused_windows(&aall);
|
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.
|
// Open a window for files in the argument list that don't have one.
|
||||||
// ARGCOUNT may change while doing this, because of autocommands.
|
// ARGCOUNT may change while doing this, because of autocommands.
|
||||||
if (count > aall.opened_len || count <= 0) {
|
if (count > aall.opened_len || count <= 0) {
|
||||||
|
@@ -148,6 +148,22 @@ function Test_tabpage()
|
|||||||
tabonly!
|
tabonly!
|
||||||
endfunc
|
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
|
" Test autocommands
|
||||||
function Test_tabpage_with_autocmd()
|
function Test_tabpage_with_autocmd()
|
||||||
command -nargs=1 -bar C :call add(s:li, '=== ' . <q-args> . ' ===')|<args>
|
command -nargs=1 -bar C :call add(s:li, '=== ' . <q-args> . ' ===')|<args>
|
||||||
|
Reference in New Issue
Block a user