Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@inkarkat
Copy link

@inkarkat inkarkat commented May 5, 2017

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. 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 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.

inkarkat added 3 commits May 5, 2017 18:18
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-io
Copy link

codecov-io commented May 5, 2017

Codecov Report

Merging #1681 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/tag.c 69.96% <100%> (+0.22%) ⬆️
src/gui.c 45.61% <0%> (+0.1%) ⬆️
src/screen.c 74.22% <0%> (+0.11%) ⬆️
src/ex_docmd.c 74.6% <0%> (+0.14%) ⬆️
src/gui_gtk_x11.c 47.33% <0%> (+0.15%) ⬆️
src/channel.c 83.85% <0%> (+0.18%) ⬆️
src/message.c 68.47% <0%> (+0.2%) ⬆️
src/term.c 53.43% <0%> (+0.23%) ⬆️
src/os_unix.c 58.68% <0%> (+0.34%) ⬆️
src/if_xcmdsrv.c 83.88% <0%> (+0.55%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4475b62...c1e21a2. Read the comment docs.

@brammool brammool closed this in 8ad80de Jun 5, 2017
@inkarkat inkarkat deleted the stag-switchbuf branch June 20, 2017 13:10
dpelle pushed a commit to dpelle/vim that referenced this pull request Jul 31, 2017
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().
janlazo added a commit to janlazo/neovim that referenced this pull request Jun 21, 2018
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
janlazo added a commit to janlazo/neovim that referenced this pull request Jun 21, 2018
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
janlazo added a commit to janlazo/neovim that referenced this pull request Jun 21, 2018
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants