helix
helix copied to clipboard
Add command to reset diff hunks
Suggested to me by @Byron
It would be nice to have a command/keybinding to reset hunks (like git reset --hard
but more fine grained).
This functionality is diff provider independent and can be implemented by just removing the after
lines in the current document and replacing the with the before
lines in the diff base.
I would implement this as a type able command (maybe :reset
) that resets the hunk at the current cursor. Ideally there would be a way to quickly place multi-cursors inside hunks so that multiple hunks can be selected at once.
That would indeed be great to have, and since I first encountered it in IntelliJ I use it regularly enough to be a staple of my workflow.
One nit would be the name of the command which seems too very general at first, and I'd definitely look for something with hunk
in the name.
That would indeed be great to have, and since I first encountered it in IntelliJ I use it regularly enough to be a staple of my workflow.
One nit would be the name of the command which seems too very general at first, and I'd definitely look for something with
hunk
in the name.
Yeah I wasn't sure about the command name maybe :reset_hunk
instead
Hi, since I didn't see any activity on this, I started an implementation.
The removal of the after
part is easy, and works more or less.
I'm unsure about returning the before
part, where should I take the change set from? Is it already preset somewhere inside the DiffHandler? Or should I calculate it myself? Or maybe I'd need to change the ChangeSet type so all changes are saved there upon initial diff?
Meanwhile I'm trying to figure out how to insert text correctly.