|
|
|
|
|
by pkill17
3655 days ago
|
|
In their diff example, line 33 on the left and 35 on the right are shown to be unchanged, however the indent isn't the same... Seems like they've hardcoded this example incorrectly unless I'm missing something? Left line 32 is removing a bracket at indent level 2, left line 33 is unchanged bracket at indent level 1, but there's now one less bracket at level 1 in the right side, even though no bracket at level 1 was removed? |
|
This is sort of what we do when diffing:
* when we need to compare two buffers, we represent them as two arrays of lines
* we then proceed to trim() each line in both arrays
* we then use a greedy optimization where the first N and the last M lines that are equal (post trimming) in both arrays are dropped from further computation
* we then run a LCS algorithm over the remaining lines to find the diffs
It is important to note that the same two arrays of lines can have multiple equal longest common substrings. This method [1] could get some love and could try to recover in some of these cases.
[1] https://github.com/Microsoft/vscode/blob/5b9ec15ce526decc5dd...