lambdalisue / vim-fern

🌿 General purpose asynchronous tree viewer written in Pure Vim script
MIT License
1.29k stars 49 forks source link

When toggling the draw with reveal, subsequent reveals of the same file name do not get revealed #136

Closed nickjj closed 4 years ago

nickjj commented 4 years ago

Repeatable steps:

  1. Create a mapping of noremap <silent> <Leader>f :Fern . -drawer -reveal=% -toggle -width=35<CR><C-w>= (thanks @bluz71)

  2. Set up something to test with

mkdir -p /tmp/testfern \
  && touch /tmp/testfern/foo \
  && touch /tmp/testfern/bar
  1. cd /tmp/testfern && vim .

  2. In Vim :e foo

  3. Use custom mapping to toggle fern open

  4. Notice how foo is selected

  5. Use custom mapping to toggle fern closed

  6. Use custom mapping to toggle fern open

  7. Notice how foo is no longer selected, instead the first item in the tree is which is the testfern directory

There's other potentially related issues too, like if you semi-randomly start clicking foo and bar to open them in a single pane and toggle the draw a few times, sometimes the wrong file will be revealed. I can't reproduce this exactly, but it happens often. This is different than the repeatable steps because in this case it reveals and highlights the wrong file, not the root item in the tree. This is more easily tested by adding the contents "foo" and "bar" to each file so you can see the foo file being open but the bar item is revealed.

lambdalisue commented 4 years ago

Confirmed with Vim. It does not happen on Neovim.

" vim -u ~/.vim/vimrc.min
if has('vim_starting')
  set nocompatible
endif

nnoremap ; :
nnoremap : ;

set packpath=
set runtimepath+=~/.config/nvim/pack/minpac/start/fern.vim

filetype plugin indent on
syntax on
  1. :e foo
  2. :Fern . -drawer -toggle -reveal=%
  3. :q
  4. :Fern . -drawer -toggle -reveal=%
lambdalisue commented 4 years ago

I fixed this issue but maybe the current correct behavior is not what you want. In that case, create a new issue as a feature request with a little more clear description of the ideal behavior @nickjj

nickjj commented 4 years ago

Hi,

The ideal behavior would be following steps 1-9 and no matter the previous state of the draw, whenever the draw becomes visible the file you have actively focused in Vim would end up being revealed / highlighted in the draw. If the draw remains open (such as not toggling), then focusing a different file / buffer in Vim would always reveal that file in the draw upon calling Fern with reveal.

I'm coming at this from the perspective of editing a file in Vim and wanting to end up in a situation where that file is now focused and revealed in the draw by hitting 1 hot key. What happens next isn't important, but typically it involves operating on the file for my most common use cases (such as renaming it, etc.) but sometimes I just want to reveal it so I can see it in the tree.

lambdalisue commented 4 years ago

I've close this while the corresponding bug has fixed.

It sounds you've to need "force reveal mode" or whatever. It would be nice to create a new issue as a feature request. Additionally, it sounds once feature explained here (https://github.com/lambdalisue/fern.vim/issues/114) would be implemented, it may help

nickjj commented 4 years ago

Thanks, if it's all the same to you, can we use #114 as that?

Or feel free to open another issue and copy / paste my previous response.