-
-
Notifications
You must be signed in to change notification settings - Fork 622
After a rename, the node loses selection #2969
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
Comments
Not able to replicate on linux/alacritty. It sounds likely a windows issue, due to the path difficulties in that OS. nvim-tree team have no access to nor expertise with windows. Please do create the PR. Please ensure changes are behind the windows feature flags
|
Thanks for looking at it! |
Ok, great, thanks for confirming! |
Co-authored-by: Lucian Ion <[email protected]>
Description
After you rename a (selected) node (file or folder) such that it changes its position in the current sorting order, the selection stays with the same number index within the tree (thus a different file/folder ending up being selected), instead of moving together with the node that was renamed.
In rename-file.lua, function fn(), there is code to update the selection:
find_file(utils.path_remove_trailing(new_file_path))
but the new_file_path variable only contains the filename or part of it (depending on the rename option chosen), rather than the entire path, even if relative.
rename() itself is called with
M.rename(node, prepend .. new_file_path .. append)
I tested and doing something like the following instead (calling find_file() with the same destination path that rename() was called with), fixes the issue (selection properly moves with the renamed node):
Could this be implemented? I wanted to run it by you rather than create a pull request in case there might be other considerations here. Thanks!
Neovim version
Operating system and version
Windows 10
Windows variant
Native Windows
nvim-tree version
1.7.1 and latest master both have the issue
Clean room replication
Steps to reproduce
In the nvim-tree window, set the selection on a node - file or folder, and then rename it with shortcut e or r. Selection doesn't move with the renamed item.
Expected behavior
Selection should move with the renamed item.
Actual behavior
Selection doesn't move with the renamed item.
The text was updated successfully, but these errors were encountered: