Skip to content

feat: Rename child buffers when renaming directory #1095

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
Mar 22, 2022

Conversation

elihunter173
Copy link
Contributor

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 and copy-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 :)

@elihunter173 elihunter173 changed the title Rename child buffers when renaming directory feat: Rename child buffers when renaming directory Mar 22, 2022
@kyazdani42 kyazdani42 merged commit 6492d43 into nvim-tree:master Mar 22, 2022
@kyazdani42
Copy link
Member

thanks :)

@elihunter173 elihunter173 deleted the rename-directory-children branch March 23, 2022 03:02
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.

2 participants