jeetsukumaran / vim-filebeagle

A VINE-spired (Vim Is Not Emacs) file system explorer.
162 stars 14 forks source link

When opening a buffer via FileBeagle, why jump to previous one first? #38

Open airblade opened 8 years ago

airblade commented 8 years ago

Here's my situation:

  1. Open a file in Vim.
  2. Press - to bring up the FileBeagle directory listing.
  3. Move the cursor to a different file and press <CR>.
  4. FileBeagle opens the file in place of its directory listing.

Between steps 3 and 4, FileBeagle jumps to the original buffer. Please could you explain why?

(I'm asking because I was surprised to see BufEnter autocommands being triggered for the original buffer as well as the new buffer instead of just for the new buffer.)

nicwest commented 8 years ago

It looks to be an artefact of the way filebeagle opens multiple files at once. I can have a bit of an investigation when I get home.

airblade commented 8 years ago

If it's necessary to jump to the original buffer, perhaps we could add a noautocmd to the command?

jeetsukumaran commented 8 years ago

I'm afraid that I have not time to look into this right now. Thank you, @nicwest, for any help you can offer!

nicwest commented 8 years ago

the multiple file thing was a red herring. this is being caused by the way filebeagle sets your previous file to be the alternate file after opening a new file. e.g.

:e file1.txt
:e file2.txt
(file2 in window, file1 is alternate)
:FileBeagle 
(open file3.txt)
(file3 in window, file2 is alternate)

if we did the same thing minus the line in question this would happen

:e file1.txt
:e file2.txt
(file2 in window, file1 is alternate)
:FileBeagle 
(open file3.txt)
(file3 in window, file1 is alternate)

When you open a file in the background (i.e straight to hidden), there is no need to revisit your previous buffer as you're not closing filebeagle.

Seeing as this buffer should be exactly as it was when you left it, running autocmds seems pretty pointless and adding the noautocmd seems like the right move to me.