Skip to content

fix(view): Don't create a new empty buffer on every open. #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2021

Conversation

sindrets
Copy link
Contributor

@sindrets sindrets commented Apr 15, 2021

Fixes #301.

Calling vnew creates a new empty buffer every time the tree opens. The window then changes to the correct buffer only a couple lines later, leaving the unused, unneeded, empty buffer behind.

@kyazdani42 kyazdani42 merged commit 4271180 into nvim-tree:master Apr 16, 2021
@Shatur
Copy link

Shatur commented Apr 16, 2021

After this PR I have an error:

E5108: Error executing lua ...im/pack/plugins/opt/nvim-tree.lua/lua/nvim-tree/view.lua:142: Vim(buffer):E86: Buffer 2 does not exist

Steps to reproduce:

:NvimTreeToggle
:setlocal bufhidden=wipe
:bd
:NvimTreeToggle

@sindrets
Copy link
Contributor Author

@Shatur95 Not related to this PR. That happened before this change. But I have created a draft for a new PR that would solve your described problem #307.

But why do you want to set bufhidden=wipe on the tree buffer?

@kyazdani42
Copy link
Member

do not set wipe, I do not recreate the buffer two time

@Shatur
Copy link

Shatur commented Apr 16, 2021

Not related to this PR. That happened before this change.

Sorry, I was wrong with the commit number :(
And thanks for the fix!

But why do you want to set bufhidden=wipe on the tree buffer?
do not set wipe, I do not recreate the buffer two time

I just have a custom function that closes the buffers. Should I add nvim-tree to exceptions or should I not use bufhidden = wipe for other buffers too?

@kyazdani42
Copy link
Member

depends the use case, but it would be better to make nvim-tree an exception because you don't want to reload the whole buffer each time when it doesn't change and doesn't consume too much ram :)

@Shatur
Copy link

Shatur commented Apr 16, 2021

depends the use case, but it would be better to make nvim-tree an exception because you don't want to reload the whole buffer each time when it doesn't change and doesn't consume too much ram :)

Thanks for the tip, will do!

@LoydAndrew
Copy link

I have the same error if I close tree with :bd or q. But I don't have buffhiden set to anything, :set buffhiden? shows buffhiden=
What do I missing? Sorry to I ask here, but this thread is kind of related.

@kyazdani42
Copy link
Member

after some time, i agree that trying to keep the tree bufnr always the same was quite a bad idea. I didn't think about users enough 😄 Maybe try to not :bd the tree then, NvimTreeClose handles that by itself already

@LoydAndrew
Copy link

Yeah, that's the thing. It doesn't work with NvimTreeClose either (and I guess pressing :q on NvimTree buffer is equivalent to NvimTreeClose).
nvimTree

Almo7aya pushed a commit to Almo7aya/nvim-tree.lua that referenced this pull request Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Everytime i toggle NvimTree, it creates a tab called [buffer]
4 participants