Skip to content
Discussion options

You must be logged in to vote

Moving a file that has unsaved changes using the snacks explorer just nukes the changes without even a warning. Is this a limitation or is there a way to configure it so that it will either

Maybe the explorer_rename/explorer_move actions should simply rename buffers instead of creating new ones (see the patch). That would avoid cases like this.

Alternatively, it can simply be renamed to an empty string and assigned buftype=nofile to prevent any possible data loss.

Caution

Saving a renamed buffer prompts "Overwrite existing file <file>". To prevent this, :edit! | undo is used to sync the buffer after renaming.

Example patch (NO WARRANTY)
diff --git a/lua/snacks/explorer/actions.lua b/lu…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@fmorroni
Comment options

@drowning-cat
Comment options

@fmorroni
Comment options

@drowning-cat
Comment options

@fmorroni
Comment options

Answer selected by fmorroni
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants