mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
vim-patch:9.1.0102: settabvar() may change the last accessed tabpage (#27450)
Problem: settabvar() may change the last accessed tabpage.
Solution: Save and restore lastused_tabpage.
(zeertzjq)
closes: vim/vim#14017
b47fbb4083
This commit is contained in:
parent
94085cfce8
commit
2493fd020d
@ -2090,6 +2090,7 @@ void f_settabvar(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
}
|
||||
|
||||
tabpage_T *const save_curtab = curtab;
|
||||
tabpage_T *const save_lu_tp = lastused_tabpage;
|
||||
goto_tabpage_tp(tp, false, false);
|
||||
|
||||
const size_t varname_len = strlen(varname);
|
||||
@ -2099,9 +2100,12 @@ void f_settabvar(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
set_var(tabvarname, varname_len + 2, varp, true);
|
||||
xfree(tabvarname);
|
||||
|
||||
// Restore current tabpage.
|
||||
// Restore current tabpage and last accessed tabpage.
|
||||
if (valid_tabpage(save_curtab)) {
|
||||
goto_tabpage_tp(save_curtab, false, false);
|
||||
if (valid_tabpage(save_lu_tp)) {
|
||||
lastused_tabpage = save_lu_tp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -995,4 +995,21 @@ func Test_tabpage_drop_tabmove()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" Test that settabvar() shouldn't change the last accessed tabpage.
|
||||
func Test_lastused_tabpage_settabvar()
|
||||
tabonly!
|
||||
tabnew
|
||||
tabnew
|
||||
tabnew
|
||||
call assert_equal(3, tabpagenr('#'))
|
||||
|
||||
call settabvar(2, 'myvar', 'tabval')
|
||||
call assert_equal('tabval', gettabvar(2, 'myvar'))
|
||||
call assert_equal(3, tabpagenr('#'))
|
||||
|
||||
bwipe!
|
||||
bwipe!
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Loading…
Reference in New Issue
Block a user