fix: change_dir with global = false does not change the working directory - #3353
fix: change_dir with global = false does not change the working directory#3353joshw1013 wants to merge 1 commit into
Conversation
Thank you for creating this pull request.
That appears to be working as documented for I am clearly not understanding the nature of the problem. Please provide a detailed test case to demonstrate the problem and a fix e.g.
|
|
Sure I can explain in more detail. I think the best way is to just show you the video of what is going on from my config. The first one is the current nvim-tree code, and the second is the one with my fix. You can see that in the first one:
If you try to reproduce it and don't see that, it's possible that without these settings it won't reset nvim-tree's root, but you should still be able to see that The reason this is going on, is that when I type Also, here's my config if it helps you at all: Let me know if it makes sense now / if you need anything else current.mp4fixed.mp4 |
|
Many thanks for the detailed reproduction. I understand the problem (directory change does not persist after quitting tree) and the solution (lcd in the buffer window). Unfortunately I don't think we can make this change:
Is there any other solution you can think of to achieve your goal? I am guessing that |
|
As a generic approach we could emit events, allowing users to do what and when they want, keeping nvim-tree itself lean. |
We could definitely add a |
Issue
With
actions.change_dir.global = false, changing the directory manually through nvim-tree fails to change to the working directory for the user. This is caused by Explorer:cd, running :lcd, which is window-scoped and applies to the current window, which is nvim-tree itself. The editing window's cwd is unchanged, so :! and pickers still resolve against the old root.Fix
My code does lcd on the target window as well, under the case that the current window is nvim-tree.