patch 9.1.1949: :stag does not use 'swichtbuf' option

Commit: 
https://github.com/vim/vim/commit/efc7509be2ba38ca6d226cf59bad67e7888a537d
Author: Yegappan Lakshmanan <[email protected]>
Date:   Wed Dec 3 19:22:13 2025 +0000

    patch 9.1.1949: :stag does not use 'swichtbuf' option
    
    Problem:  :stag does not use 'swichtbuf' option, though the
              documentation states differently
              (Christian Brabandt)
    Solution: Respect 'switchbuf' option (Yegappan Lakshmanan).
    
    related: #18845
    closes: #18856
    
    Signed-off-by: Yegappan Lakshmanan <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt
index 5b77055a6..7b8248655 100644
--- a/runtime/doc/windows.txt
+++ b/runtime/doc/windows.txt
@@ -1,4 +1,4 @@
-*windows.txt*  For Vim version 9.1.  Last change: 2025 Nov 11
+*windows.txt*  For Vim version 9.1.  Last change: 2025 Dec 03
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -878,13 +878,15 @@ the buffer.  The result is that all buffers will use the 
'encoding' encoding
                                                        *:sta* *:stag*
 :sta[g][!] [tagname]
                Does ":tag[!] [tagname]" and splits the window for the found
-               tag.  See also |:tag|.
+               tag.  Refer to 'switchbuf' to jump to a tag in a vertically
+               split window or a new tab page.  See also |:tag|.
 
 CTRL-W ]                                       *CTRL-W_]* *CTRL-W_CTRL-]*
 CTRL-W CTRL-]  Split current window in two.  Use identifier under cursor as a
                tag and jump to it in the new upper window.
                In Visual mode uses the Visually selected text as a tag.
-               Make new window N high.
+               Make new window N high.  Refer to 'switchbuf' to jump to a tag
+               in a vertically split window or a new tab page.
 
                                                        *CTRL-W_g]*
 CTRL-W g ]     Split current window in two.  Use identifier under cursor as a
diff --git a/src/tag.c b/src/tag.c
index 23573fe88..60b38d156 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -3850,6 +3850,15 @@ jumpto_tag(
     if (getfile_result == GETFILE_UNUSED
                                  && (postponed_split || cmdmod.cmod_tab != 0))
     {
+       if (swb_flags & SWB_VSPLIT)
+           // If 'switchbuf' contains 'vsplit', then use a new vertically
+           // split window.
+           cmdmod.cmod_split |= WSP_VERT;
+
+       if (swb_flags & SWB_NEWTAB)
+           // If 'switchbuf' contains 'newtab', then use a new tabpage
+           cmdmod.cmod_tab = tabpage_index(curtab) + 1;
+
        if (win_split(postponed_split > 0 ? postponed_split : 0,
                                                postponed_split_flags) == FAIL)
        {
diff --git a/src/testdir/test_tagjump.vim b/src/testdir/test_tagjump.vim
index 47618d077..5ddaaadc2 100644
--- a/src/testdir/test_tagjump.vim
+++ b/src/testdir/test_tagjump.vim
@@ -144,6 +144,24 @@ func Test_tagjump_switchbuf()
   1tabnext | stag third
   call assert_equal(2, tabpagenr('$'))
   call assert_equal(3, line('.'))
+  tabonly
+
+  " use a vertically split window
+  enew | only
+  set switchbuf=vsplit
+  stag third
+  call assert_equal(2, winnr('$'))
+  call assert_equal(1, winnr())
+  call assert_equal(3, line('.'))
+  call assert_equal(['row', [['leaf', win_getid(1)], ['leaf', win_getid(2)]]], 
winlayout())
+
+  " jump to a tag in a new tabpage
+  enew | only
+  set switchbuf=newtab
+  stag second
+  call assert_equal(2, tabpagenr('$'))
+  call assert_equal(2, tabpagenr())
+  call assert_equal(2, line('.'))
 
   tabclose!
   enew | only
diff --git a/src/version.c b/src/version.c
index b9c5409dc..186cddf80 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1949,
 /**/
     1948,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vQsY8-00EmNx-7N%40256bit.org.

Raspunde prin e-mail lui