-
-
Couldn't load subscription status.
- Fork 5.9k
Make :stag observe the 'switchbuf' option #1681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The useopen and usetab values of 'switchbuf' should (according to :help 'swb') be _used in all buffer related split commands, for example ":sbuffer", ":sbnext", or ":sbrewind"._ The :stag / :stselect / :stjump commands also split windows and open a new buffer. Therefore, users expect them to be influenced by 'switchbuf' as well, but they currently are not. When navigating tags, :set switchbuf=useopen can have great benefits: It avoids that multiple buffers with the same source file are opened; users will end up with the minimum amount of split windows, just one for each source file, and do not have to manually manage duplicate window splits. The implementation in jumpto_tag() parallels the one in buflist_getfile(). getfile_result, already used later as a flag is now initialized at the beginning of the function, and used to actually skip the getfile() call if a window reuse has happened.
This tests the default (empty) 'switchbuf' behavior (new split window), "useopen" (second :stag reuses current file), "usetab" (second :stag reuses file in different tab page).
The debugger showed me that fname is a relative one (.\foo.c) on Windows; buflist_findname() expects a full one (ffname). Therefore, need to use buflist_findname_exp() to resolve fname into ffname. I'm not sure why this works on Linux without the conversion, though...
Codecov Report
@@ Coverage Diff @@
## master #1681 +/- ##
==========================================
+ Coverage 74.85% 74.91% +0.05%
==========================================
Files 76 76
Lines 124942 124954 +12
==========================================
+ Hits 93521 93604 +83
+ Misses 31421 31350 -71
Continue to review full report at Codecov.
|
Problem: The ":stag" command does not respect 'switchbuf'.
Solution: Check 'switchbuf' for tag commands that may open a new window.
(Ingo Karkat, closes vim#1681) Define macros for the return values
of getfile().
Problem: The ":stag" command does not respect 'switchbuf'.
Solution: Check 'switchbuf' for tag commands that may open a new window.
(Ingo Karkat, closes vim/vim#1681) Define macros for the return values
of getfile().
vim/vim@8ad80de
Problem: The ":stag" command does not respect 'switchbuf'.
Solution: Check 'switchbuf' for tag commands that may open a new window.
(Ingo Karkat, closes vim/vim#1681) Define macros for the return values
of getfile().
vim/vim@8ad80de
Problem: The ":stag" command does not respect 'switchbuf'.
Solution: Check 'switchbuf' for tag commands that may open a new window.
(Ingo Karkat, closes vim/vim#1681) Define macros for the return values
of getfile().
vim/vim@8ad80de
The
useopenandusetabvalues of'switchbuf'should (according to:help 'swb') be used in all buffer related split commands, for example ":sbuffer", ":sbnext", or ":sbrewind".The
:stag/:stselect/:stjumpcommands also split windows and open a new buffer. Therefore, users expect them to be influenced by'switchbuf'as well, but they currently are not. When navigating tags,:set switchbuf=useopencan have great benefits: It avoids that multiple buffers with the same source file are opened; users will end up with the minimum amount of split windows, just one for each source file, and do not have to manually manage duplicate window splits. This deleted question on Stack Overflow asks for this explicitly. I want this, too, and think this is a change that most users would welcome, and would add more consistency to the Vim command set. Users that don't like this behavior probably don't have'switchbuf'configured, anyway.The implementation in
jumpto_tag()parallels the one inbuflist_getfile().getfile_result, already used later as a flag is now initialized at the beginning of the function, and used to actually skip thegetfile()call if a window reuse has happened.