wincent / command-t

⌨️ Fast file navigation for Neovim and Vim
BSD 2-Clause "Simplified" License
2.74k stars 317 forks source link

Veritical split opening of already opened file doesn't work. #339

Closed a-d-v-e-n-t-u-r-o-u-s closed 5 years ago

a-d-v-e-n-t-u-r-o-u-s commented 6 years ago

Hello, here is the scenario with which I got problem, maybe someone can help me with that:

Generally I'm using default settings of CommandT and current master from the SHA-1 sum: 7147ba92c9c1eef8269fd47d47ba636ce7f365a6

wincent commented 6 years ago

The code responsible for this behavior is in: https://github.com/wincent/command-t/blob/7147ba92c9c1eef8269fd47d47ba636ce7f365a6/autoload/commandt.vim#L172-L185

It's basically trying to prioritize switching to a pre-existing view of buffer rather than opening a new one. I can see, though, why you might want to deprioritize things when the operation was explicitly "open this result in a vertical split" (and similarly for horizontal splits and probably tabs too). There are a lot of subtle nuances though (see https://github.com/wincent/wincent/commit/8a95c3dba72616e03e62b2ffaabbea83392f983c for example), so may want to think about this carefully before making a change.

artnez commented 6 years ago

I had to revert back to an older version of Command-T. The new behavior messed up my workflow after years of muscle memory. I'm often hacking on multiple sections of the same file in a vertical split. Simply choosing an already open file will jump that file instead of opening it (in all cases).

If there was an option to disable GotoOrOpen I'd be happy to flip it on.

a-d-v-e-n-t-u-r-o-u-s commented 6 years ago

By me is the use case similar as by artnez, I'm often using vertical splits on the same files. So generally in order to have this functionality we must change code snippet, which you have shown us.

kentaroi commented 6 years ago

Thank you very much for creating and maintaining this great plugin, @wincent . However, I cannot accept this new behaviour.

I understand what I am doing. When I am opening a file with Command-T in a split, I do NOT want to move to another split, but want to open the file in that split. If I want to move to another split, I move to that split without Command-T.

wincent commented 6 years ago

Not really "new" behavior (the commit I linked to above is from four years ago, and merely brought things closer to the intended behavior). I'm happy to add some option for this, carefully (like I said above, there are many subtleties and nuances to take into account), and in the meantime you can revert back to an older version or hack the code yourself. Technically you should be able to have it without any code changes by resourceful manipulation of the g:CommandTAcceptSelectionSplitCommand (etc) settings, which can be used to completely bypass the CommandTOpen command (which is the one calling commandt#GotoOrOpen).

kentaroi commented 6 years ago

Thank you very much for the quick reply and kind comments and suggestions, @wincent . I'm sorry I misunderstood. I just reverted back to version 4.0, and will look into g:CommandTAcceptSelectionSplitCommand etc. I'm sorry to have bothered you by my complaint without looking into the settings. Thank you again very much.

wincent commented 5 years ago

So I just cut v5.0.3 from the next branch, and merged next into master too. I had forgotten, but a while back #315 changed the behavior here. I am not sure if that changes any of the points made here so far.

a-d-v-e-n-t-u-r-o-u-s commented 5 years ago

I've temporary hacked my .vimrc file in following commit:

https://github.com/a-d-v-e-n-t-u-r-o-u-s/.dotfiles/commit/18e9bda5e50aeb2f42082be3febd5fb1b9fe18a8

I'm going to test it for a few days to see if this is working for me. @wincent thank you very much for hints.