pascalkuthe / imara-diff

Reliably performant diffing
Apache License 2.0
106 stars 9 forks source link

allow for sinks to abort diff halfway through #12

Closed loftyinclination closed 1 month ago

loftyinclination commented 1 month ago

I'm creating a program that allows for reviewing code changes in a git add --patch manner; for each hunk, I want to get feedback from the user on whether the change should be approved or not.

One way I could see to accomplish this would be to write a custom Sink that would return a Result, and allow for processing to be cancelled halfway through. Would this be something that you'd imagine would fit into this crate, or would you have another idea for how to go about this change?

pascalkuthe commented 1 month ago

that is not feasible with how diffing algorithms work. I will also evolve the API in the future to remove the sink trait altogether so I can do further postprocessing.

Simply collect all the changes in a Vec and then iterate trough that list. That's also how git add --patch works