Skip to content
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

Add command to reset diff hunks #4974

Closed
pascalkuthe opened this issue Dec 2, 2022 · 3 comments · Fixed by #5736
Closed

Add command to reset diff hunks #4974

pascalkuthe opened this issue Dec 2, 2022 · 3 comments · Fixed by #5736
Assignees
Labels
A-vcs Area: Version control system interaction C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much

Comments

@pascalkuthe
Copy link
Member

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.

@pascalkuthe pascalkuthe added C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much labels Dec 2, 2022
@pascalkuthe pascalkuthe self-assigned this Dec 2, 2022
@Byron
Copy link
Contributor

Byron commented Dec 2, 2022

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.

@pascalkuthe pascalkuthe changed the title Addd command to reset a diff hunks Add command to reset a diff hunks Dec 2, 2022
@pascalkuthe
Copy link
Member Author

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

@pascalkuthe pascalkuthe changed the title Add command to reset a diff hunks Add command to reset diff hunks Dec 2, 2022
@pascalkuthe pascalkuthe added the A-vcs Area: Version control system interaction label Dec 3, 2022
@nabaco
Copy link
Contributor

nabaco commented Jan 24, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-vcs Area: Version control system interaction C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants