elihunter173 / dirbuf.nvim

A file manager for Neovim which lets you edit your filesystem like you edit text
GNU Affero General Public License v3.0
426 stars 6 forks source link

Feature: Command to dry-run saving a Dirbuf #4

Closed elihunter173 closed 2 years ago

elihunter173 commented 2 years ago

u/sectiu made a comment on Reddit suggesting

I could see myself removing things by accident. It'd be very useful to have a dirvish's Shdo equivalent so we can inspect the operations to be performed beforehand.

I'm thinking of adding a command like :DirbufDryRun. It would generate a plan like dirbuf.sync() does and then pretty print the results, probably using shell-like commands like mv foo bar. So for example changes like this

a #a
b #b
c #c

-- After edits -->
a #b

would generate a dry-run output like (possibly re-ordered)

mv b a
rm c

If we add a command like this, I think it also makes sense to add a command like :DirbufSync just for symmetry. Maybe dry run could even be an option for :DirbufSync?

elihunter173 commented 2 years ago

This functionality has been implemented with a new command: :DirbufSync. This command does the same thing as :writeing the directory buffer, but it also has a -dry-run flag. When -dry-run is specified, the buffer isn't synced and instead the appropriate actions are printed in a shell-like format the issue mentioned.

See :help dirbuf-:DirbufSync for more info