ctrlpvim / ctrlp.vim

Active fork of kien/ctrlp.vim—Fuzzy file, buffer, mru, tag, etc finder.
ctrlpvim.github.com/ctrlp.vim
Other
5.57k stars 261 forks source link

Leaving E or e out of ctrlp_switch_buffer switches to an open buffer #169

Open bryanforbes opened 8 years ago

bryanforbes commented 8 years ago

This issue was introduced with #55. To reproduce the issue:

  1. Set let g:ctrlp_switch_buffer='vt' in ~/.vimrc
  2. :e ~/A.txt
  3. :vsp ~/B.txt (focus should be in the window for ~/B.txt)
  4. :CtrlPBuffer
  5. Press Enter on the entry for ~/A.txt

The focus will now move from the window for B.txt to the window for A.txt. The expected behavior is that the buffer for A.txt will display in the window where B.txt is displayed:

When opening a file, if it's already open in a window somewhere, CtrlP will try to jump to it instead of opening a new instance: > let g:ctrlp_switch_buffer = 'Et' < e - jump when is pressed, but only to windows in the current tab. t - jump when is pressed, but only to windows in another tab. v - like "e", but jump when is pressed. h - like "e", but jump when is pressed. E, T, V, H - like "e", "t", "v", and "h", but jump to windows anywhere. 0 or - disable this feature.

According to the docs, leaving E or e out of the string should prevent jumping to windows. From reading #38, it seems that the conditional needs further tweaking. When setting ctrlp_switch_buffer to a string without E or e but not 0 (for instance vt):

This causes jmpb to be set which triggers the behavior of switching to an existing buffer at line 1048.

tacahiroy commented 8 years ago

indeed - it behaves unexpectedly. will take a look

tacahiroy commented 8 years ago

I've made a tiny fix for this and it work: 7cad1dc Can anyone check this?

bryanforbes commented 8 years ago

This fix seems to work. I only tested my use-case, so I'm unsure if it possibly reverts the fix for #38. @gelguy, can you check this fix too?

thefron commented 8 years ago

The fix works to me also.

svanharmelen commented 8 years ago

@tacahiroy fix seems to work great for me too :+1:

EDIT: Hmm, maybe not... Still don't have consistent behaviour when opening files. I expect it to open in my active split, but it doesn't do that consistently.

gelguy commented 8 years ago

Sorry for the delay. The fix for #38 was just a type conversion check so it is quite unrelated to this issue.

The md =~ '[et]' check is now missing so the setting g:ctrlp_switch_buffer to anything with e or t might result in unexpected behaviour.

I'm rather rusty with the codebase right now but I'll see if I can find a solution.