feat: Rename child buffers when renaming directory #1095
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR tweaks
utils.rename_loaded_buffers()
behavior so now, along with renaming any exact name matches (for renaming all loaded instances of a file), it renames all children of the old path. This makes it so that renaming a directory also updates the names of any files opened within that directory or any of its subdirectories. This also makes it so:write!
is only issued for ordinary files.I've done basic manual testing of this change with nvim-tree.lua using both the
rename-file
andcopy-paste
actions.For background, I recently added a feature to dirbuf.nvim where buffers are automatically renamed on moves (elihunter173/dirbuf.nvim#18) and I stole nvim-tree.lua's code to do this! Then I enhanced it to work with directories (and not break with dirbufs), so I figured I'd pay it back :)