diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 36209a8db9..987d48c74a 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -2869,7 +2869,7 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, bool keep_help) cmdmod.cmod_split |= WSP_VERT; } - if (swb_flags & kOptSwbFlagNewtab) { + if ((swb_flags & kOptSwbFlagNewtab) && cmdmod.cmod_tab == 0) { // If 'switchbuf' contains 'newtab', then use a new tabpage cmdmod.cmod_tab = tabpage_index(curtab) + 1; } diff --git a/test/old/testdir/test_tagjump.vim b/test/old/testdir/test_tagjump.vim index 15f5932f96..df9f7060fa 100644 --- a/test/old/testdir/test_tagjump.vim +++ b/test/old/testdir/test_tagjump.vim @@ -163,7 +163,12 @@ func Test_tagjump_switchbuf() call assert_equal(2, tabpagenr('$')) call assert_equal(2, tabpagenr()) call assert_equal(2, line('.')) + 0tab stag third + call assert_equal(3, tabpagenr('$')) + call assert_equal(1, tabpagenr()) + call assert_equal(3, line('.')) + tabclose! tabclose! enew | only set tags&