Skip to content

Commit

Permalink
Set switchbuf if it is empty (the default)
Browse files Browse the repository at this point in the history
Try to avoid people running into this issue:

  #289

If people end up complaining about this will have to document how to
avoid this (ie. by setting up a non-default setting in `~/.vim/vimrc`,
or setting back to the empty default in an "after" file).
  • Loading branch information
wincent committed Jun 8, 2017
1 parent c62079d commit 3f0d21a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugin/command-t.vim
Expand Up @@ -8,6 +8,10 @@ let g:command_t_loaded = 1

command! -nargs=+ CommandTOpen call commandt#GotoOrOpen(<q-args>)

if empty(&switchbuf)
set switchbuf=usetab
endif

" HACK: use both old and new during early development
if has('patch-7-4-1829') && get(g:, 'CommandTEngine', 'mirkwood') ==? 'isengard'
call commandt#isengard#init()
Expand Down

3 comments on commit 3f0d21a

@mrubli
Copy link

@mrubli mrubli commented on 3f0d21a Nov 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like to be the one to "complain" but here goes. ;-)

I just ran into the problem you're alluding to in the commit message while using https://github.com/derekwyatt/vim-fswitch. I noticed that plugin's behavior was different on two of my machines and eventually traced it back to switchbuf being set by command-t on one of them.

I'm not sure I would have found it if it had been documented but perhaps this mechanism here would work for command-t as well?
https://github.com/AndrewRadev/linediff.vim/blob/master/autoload/linediff/controller.vim#L83
It has the advantage of leaving the user's switchbuf setting intact while still temporarily changing the behavior.

@wincent
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@murbli: does the discussion on #309 resolve this satisfactorily for you?

@mrubli
Copy link

@mrubli mrubli commented on 3f0d21a May 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wincent Thanks for following up and the pointer. Setting switchbuf=useopen isn't an option for me because I specifically don't want that behavior. My goal in this specific case is for :FSHere to not reuse any open windows at all, so switchbuf= is the only valid option for me.

I ended up working around it by clearing switchbuf before calling :FSHere. According to my notes resetting it after command-t is loaded didn't work for me if the vim-command-t Debian package was installed but I can't recall whether I tried the after-directory at the time.

I guess I still think that only temporarily changing the setting is the cleanest option for a plug-in but my workaround works for me. :-)

Please sign in to comment.