mirror of
https://github.com/vim/vim.git
synced 2025-07-24 10:45:12 -04:00
adds option to control whether tagstack is copied to new window
fixes: #5742
This commit is contained in:
parent
99b9847bd8
commit
e7de891f27
@ -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.
|
||||
Also see 'preserveindent'.
|
||||
|
||||
*'copytagstack'* *'cptgst'* *'nocopytagstack'* *'nocptgst'*
|
||||
'copytagstack' 'cptgst' boolean (default: on)
|
||||
global
|
||||
Copy tag stack when splitting window.
|
||||
|
||||
*'cpoptions'* *'cpo'* *cpo*
|
||||
'cpoptions' 'cpo' string (Vim default: "aABceFsz",
|
||||
Vi default: all flags, except "#{|&/\."
|
||||
|
@ -422,6 +422,7 @@ EXTERN char_u *p_ofu; // 'omnifunc'
|
||||
EXTERN char_u *p_tsrfu; // 'thesaurusfunc'
|
||||
#endif
|
||||
EXTERN int p_ci; // 'copyindent'
|
||||
EXTERN int p_cptgst; // 'copytagstack'
|
||||
#if defined(FEAT_GUI) && defined(MACOS_X)
|
||||
EXTERN int *p_antialias; // 'antialias'
|
||||
#endif
|
||||
|
@ -727,6 +727,9 @@ static struct vimoption options[] =
|
||||
{"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
|
||||
(char_u *)&p_ci, PV_CI, NULL, NULL,
|
||||
{(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,
|
||||
(char_u *)&p_cpo, PV_NONE, did_set_cpoptions, expand_set_cpoptions,
|
||||
{(char_u *)CPO_VI, (char_u *)CPO_VIM}
|
||||
|
@ -114,6 +114,7 @@ NEW_TESTS = \
|
||||
test_compiler \
|
||||
test_conceal \
|
||||
test_const \
|
||||
test_copytagstack \
|
||||
test_cpoptions \
|
||||
test_crash \
|
||||
test_crypt \
|
||||
@ -398,6 +399,7 @@ NEW_TESTS_RES = \
|
||||
test_comparators.res \
|
||||
test_conceal.res \
|
||||
test_const.res \
|
||||
test_copytagstack.res \
|
||||
test_cpoptions.res \
|
||||
test_crash.res \
|
||||
test_crypt.res \
|
||||
|
46
src/testdir/test_copytagstack.vim
Normal file
46
src/testdir/test_copytagstack.vim
Normal 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
|
21
src/window.c
21
src/window.c
@ -1559,17 +1559,20 @@ win_init(win_T *newp, win_T *oldp, int flags UNUSED)
|
||||
}
|
||||
|
||||
// copy tagstack and folds
|
||||
for (i = 0; i < oldp->w_tagstacklen; i++)
|
||||
if (p_cptgst)
|
||||
{
|
||||
taggy_T *tag = &newp->w_tagstack[i];
|
||||
*tag = oldp->w_tagstack[i];
|
||||
if (tag->tagname != NULL)
|
||||
tag->tagname = vim_strsave(tag->tagname);
|
||||
if (tag->user_data != NULL)
|
||||
tag->user_data = vim_strsave(tag->user_data);
|
||||
for (i = 0; i < oldp->w_tagstacklen; i++)
|
||||
{
|
||||
taggy_T *tag = &newp->w_tagstack[i];
|
||||
*tag = oldp->w_tagstack[i];
|
||||
if (tag->tagname != NULL)
|
||||
tag->tagname = vim_strsave(tag->tagname);
|
||||
if (tag->user_data != NULL)
|
||||
tag->user_data = vim_strsave(tag->user_data);
|
||||
}
|
||||
newp->w_tagstackidx = oldp->w_tagstackidx;
|
||||
newp->w_tagstacklen = oldp->w_tagstacklen;
|
||||
}
|
||||
newp->w_tagstackidx = oldp->w_tagstackidx;
|
||||
newp->w_tagstacklen = oldp->w_tagstacklen;
|
||||
|
||||
// Keep same changelist position in new window.
|
||||
newp->w_changelistidx = oldp->w_changelistidx;
|
||||
|
Loading…
x
Reference in New Issue
Block a user