You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So here is an interesting problem, i have. I would usually open a new tree in a separate tab to explore or mutate a given working directory, say in the first vim tab i open a file and a normal side view of nvim tree for the same working directory of the file just opened, on the second tab i would open nvim tree only in the home directory (for example :e ~/). Now in the second tab i will expand the tree view in some folder from the home. I navigate back to the first tab, my configuration would trigger a DirChanged event, and the tree in the first tab would show correctly the view it did initially. However going back to the tab displaying the home folder, DirChanged will trigger again, and will be for the home directory, however the tree would auto-colapse, losing its expanded state it had before i left that home-dir tab, which is quite annoying to be frank, the directory for that tree technically did not change it is still /home, but i do know that nvim tree somehow reuses the same buffer and triggers redraws. Looking at the code i could see that if i disable opts.sync_root_with_cwd, can help, but breaks other things. This function M.change_dir(vim.loop.cwd()) in its implementation redraws the tree. So i assume it does not store the state, or knows that.
open the tree for that directory using the api.tree.open
open new tab in another directory, open the tree there
start expanding, collapsing, navigating, mutating the tree view
navigate to the first tab, tcd path-to-work-dir
navigate back to the second, tcd path-to-second-dir
Expected behavior
The tree state should be remembered, when going back and forth between directories.
Actual behavior
The tree state is not remembered, rather going back to the same tree, the entire tree only shows the root folders of the directory for which it was opened.
The text was updated successfully, but these errors were encountered:
That tabbed behaviour is not surprising. Tree state and (local) cwd state is not handled across tabs. We can follow it at the pinned issue #2255
Ignoring tabs, this is still an issue: the tree state is not remembered when :cd up and down diretories. Watchers are destroyed and recreated however git state cache is retained and used.
Description
So here is an interesting problem, i have. I would usually open a new tree in a separate tab to explore or mutate a given working directory, say in the first vim tab i open a file and a normal side view of nvim tree for the same working directory of the file just opened, on the second tab i would open nvim tree only in the home directory (for example :e ~/). Now in the second tab i will expand the tree view in some folder from the home. I navigate back to the first tab, my configuration would trigger a DirChanged event, and the tree in the first tab would show correctly the view it did initially. However going back to the tab displaying the home folder, DirChanged will trigger again, and will be for the home directory, however the tree would auto-colapse, losing its expanded state it had before i left that home-dir tab, which is quite annoying to be frank, the directory for that tree technically did not change it is still /home, but i do know that nvim tree somehow reuses the same buffer and triggers redraws. Looking at the code i could see that if i disable
opts.sync_root_with_cwd
, can help, but breaks other things. This functionM.change_dir(vim.loop.cwd())
in its implementation redraws the tree. So i assume it does not store the state, or knows that.Neovim version
Operating system and version
Fedora 38
Windows variant
No response
nvim-tree version
master
Clean room replication
Steps to reproduce
Expected behavior
The tree state should be remembered, when going back and forth between directories.
Actual behavior
The tree state is not remembered, rather going back to the same tree, the entire tree only shows the root folders of the directory for which it was opened.
The text was updated successfully, but these errors were encountered: