NvimTree does not open the file when it is open standalone
wookayin opened this issue · comments
When nvim-tree is working when "hijacking" directory buffers, it cannot open the file.
Reproduce:
vim .
(or after entering vim,e .
,vs .
, etc.)- At this point, NvimTree will open in place of netrw (because it hijacks netrw upon FileExplorer)
- Press
<CR>
to open any file - Nothing happens
It should work as Nerdtree and netrw would do.
Expected behavior:
- Open the file
- The current window (directory explorer) will be replaced by the file
This is because nvim-tree.lib.Tree.target_winid
is nil
https://github.com/kyazdani42/nvim-tree.lua/blob/master/lua/nvim-tree/lib.lua#L346-L350
so, what one could do to fix it?
for example, I've "hacked" it around by update_to_buf_dir=false
(semi-sizes situation by itself) and au VimEnter * :bwipeout
(because I hate that it keeps useless buffer after openinig the file) :D
But proper fix would be to bisect the code and revert the change when it become broken.
Or to fix it another way and create a PR.
well, and yes, I've disabled the picker.
@msva That would be a great workaround, at least the default netrw or nerdtree would work well.
Ideally we would keep NvimTree handle the directory buffer, but this seems to require quite lines of changes.
@i1skn I tried adding to L349 target_winid = api.nvim_get_current_win()
to force nvim-tree to open the file in the "current" window (the same one as the directory buffer), but the nvim-tree window will still appear in the left (with some blinking UI glitches), which should be fixed by improving other relevant procedures.
@kyazdani42 Any updates?
#815 works to fix the bug itself, but it still doesn't work same as the netrw explorer when opening a directory buffer (e.g., only one nvim-tree buffer can present). I will open another issue about this. Thank you for the fix.