feat: move directories while updating buffer paths (supercharged :move
)
#12923
+74
−22
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.
:move
is nice, but it doesn't let you move a directory and automatically update the buffer paths for any files inside of it that are opened in the editor. Currently this is rather cumbersome, you need to:sh mv foo bar
, close all affected buffers, then reopen them again at their new paths.This PR proposes a couple of changes:
Editor::move_path
now handles updating the paths for all affected buffers when it moves a directory.:move
takes 1 to n arguments. If a single argument is given, the argument is the destination path and the buffer path is the source (this is the existing behavior, which continues to work as before). If multiple arguments are given,:move
behaves like the Unixmv
command::move foo bar
movesfoo
tobar
,:move foo bar baz
movesfoo
andbar
intobaz
.:move foo bar
knows to movefoo
tobar/foo
ifbar
is an existing directory. Again this mirrors the behavior of Unixmv
and should be more intuitive.I think this is a natural extension to the existing behavior and has worked very well for me during testing so far. Any suggestions or feedback is appreciated :)