[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Improvement to choose more logical places for changed regions

From: Piotr Siupa
Subject: Improvement to choose more logical places for changed regions
Date: Thu, 25 Mar 2021 18:01:41 +0100


There is a very common situation when I'm adding/removing an entire
function to/from e.t.c. The diff often shows the added/removed text to
start in the middle of the function and end in the middle of the next
function if its starting lines match. (Attached files "f1" and "f2" have
some silly pseudo-code which shows an example of that situation when
I think this inconvenience can be very easily fixed by using a heuristic
that the exact position of the changed region should be chosen in that way
that it starts and ends on the shortest lines possible. This is a simple
heuristic but it should cover 90% of the cases.
I've modified the code as a proof of concept (attachment "source_diff") and
it seems to work quite well. (The code is not quite finished nor tested and
it requires option -c or -u to work but it's good enough to show the idea.)
I will finish it if I get a green light for it.

Attachment: f1
Description: Binary data

Attachment: f2
Description: Binary data

Attachment: source_diff
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]