0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

adds option to control whether tagstack is copied to new window

fixes: #5742
This commit is contained in:
Yuri Gribov 2025-06-21 05:16:43 +00:00 committed by Yury Gribov
parent 99b9847bd8
commit e7de891f27
6 changed files with 69 additions and 9 deletions

View File

@ -2356,6 +2356,11 @@ A jump table for the options with a short description can be found at |Q_op|.
NOTE: This option is reset when 'compatible' is set. NOTE: This option is reset when 'compatible' is set.
Also see 'preserveindent'. Also see 'preserveindent'.
*'copytagstack'* *'cptgst'* *'nocopytagstack'* *'nocptgst'*
'copytagstack' 'cptgst' boolean (default: on)
global
Copy tag stack when splitting window.
*'cpoptions'* *'cpo'* *cpo* *'cpoptions'* *'cpo'* *cpo*
'cpoptions' 'cpo' string (Vim default: "aABceFsz", 'cpoptions' 'cpo' string (Vim default: "aABceFsz",
Vi default: all flags, except "#{|&/\." Vi default: all flags, except "#{|&/\."

View File

@ -422,6 +422,7 @@ EXTERN char_u *p_ofu; // 'omnifunc'
EXTERN char_u *p_tsrfu; // 'thesaurusfunc' EXTERN char_u *p_tsrfu; // 'thesaurusfunc'
#endif #endif
EXTERN int p_ci; // 'copyindent' EXTERN int p_ci; // 'copyindent'
EXTERN int p_cptgst; // 'copytagstack'
#if defined(FEAT_GUI) && defined(MACOS_X) #if defined(FEAT_GUI) && defined(MACOS_X)
EXTERN int *p_antialias; // 'antialias' EXTERN int *p_antialias; // 'antialias'
#endif #endif

View File

@ -727,6 +727,9 @@ static struct vimoption options[] =
{"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM, {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
(char_u *)&p_ci, PV_CI, NULL, NULL, (char_u *)&p_ci, PV_CI, NULL, NULL,
{(char_u *)FALSE, (char_u *)0L} SCTX_INIT}, {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"copytagstack", "cptgst", P_BOOL|P_VIM,
(char_u *)&p_cptgst, PV_NONE, NULL, NULL,
{(char_u *)TRUE, (char_u *)TRUE} SCTX_INIT},
{"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST, {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
(char_u *)&p_cpo, PV_NONE, did_set_cpoptions, expand_set_cpoptions, (char_u *)&p_cpo, PV_NONE, did_set_cpoptions, expand_set_cpoptions,
{(char_u *)CPO_VI, (char_u *)CPO_VIM} {(char_u *)CPO_VI, (char_u *)CPO_VIM}

View File

@ -114,6 +114,7 @@ NEW_TESTS = \
test_compiler \ test_compiler \
test_conceal \ test_conceal \
test_const \ test_const \
test_copytagstack \
test_cpoptions \ test_cpoptions \
test_crash \ test_crash \
test_crypt \ test_crypt \
@ -398,6 +399,7 @@ NEW_TESTS_RES = \
test_comparators.res \ test_comparators.res \
test_conceal.res \ test_conceal.res \
test_const.res \ test_const.res \
test_copytagstack.res \
test_cpoptions.res \ test_cpoptions.res \
test_crash.res \ test_crash.res \
test_crypt.res \ test_crypt.res \

View File

@ -0,0 +1,46 @@
" test 'copytagstack' option
source check.vim
source view_util.vim
func Test_copytagstack()
call writefile(["int Foo;"], 'file.c', 'D')
call writefile(["Foo\tfile.c\t1"], 'Xtags', 'D')
set tags=Xtags
tag Foo
let nr0 = winnr()
call assert_equal(1, gettagstack(nr0)['length'])
split Xtext
let nr1 = winnr()
call assert_equal(1, gettagstack(nr1)['length'])
set tags&
bwipe
endfunc
func Test_nocopytagstack()
call writefile(["int Foo;"], 'file.c', 'D')
call writefile(["Foo\tfile.c\t1"], 'Xtags', 'D')
set tags=Xtags
set nocopytagstack
tag Foo
let nr0 = winnr()
call assert_equal(1, gettagstack(nr0)['length'])
split Xtext
let nr1 = winnr()
call assert_equal(0, gettagstack(nr1)['length'])
set tags&
set copytagstack&
bwipe
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -1559,6 +1559,8 @@ win_init(win_T *newp, win_T *oldp, int flags UNUSED)
} }
// copy tagstack and folds // copy tagstack and folds
if (p_cptgst)
{
for (i = 0; i < oldp->w_tagstacklen; i++) for (i = 0; i < oldp->w_tagstacklen; i++)
{ {
taggy_T *tag = &newp->w_tagstack[i]; taggy_T *tag = &newp->w_tagstack[i];
@ -1570,6 +1572,7 @@ win_init(win_T *newp, win_T *oldp, int flags UNUSED)
} }
newp->w_tagstackidx = oldp->w_tagstackidx; newp->w_tagstackidx = oldp->w_tagstackidx;
newp->w_tagstacklen = oldp->w_tagstacklen; newp->w_tagstacklen = oldp->w_tagstacklen;
}
// Keep same changelist position in new window. // Keep same changelist position in new window.
newp->w_changelistidx = oldp->w_changelistidx; newp->w_changelistidx = oldp->w_changelistidx;