commit - c672cd5263e14c546a06d2b2132fd05bf20bbca0
commit + f6db314590fc96c0cdbf87367b47da8603e17ae9
blob - 3707ff39d6fbd6d28afc2a01bc56bd367ffec06c
blob + 69aea0a6aaf3ddfe78f7567e8a2405ae2d0c81e0
--- lib/diff_main.c
+++ lib/diff_main.c
struct diff_chunk *new_chunk;
enum diff_chunk_type last_t;
enum diff_chunk_type new_t;
+ struct diff_chunk *last;
/* Append to solved chunks; make sure that adjacent chunks of same type are combined, and that a minus chunk
* never directly follows a plus chunk. */
if (!new_chunk)
return NULL;
*new_chunk = *chunk;
+
+ /* The new minus chunk indicates to which position on
+ * the right it corresponds, even though it doesn't add
+ * any lines on the right. By moving above a plus chunk,
+ * that position on the right has shifted. */
+ last = &result->head[result->len - 1];
+ new_chunk->right_start = last->right_start;
debug(" - added minus-chunk follows plus-chunk,"
" put before that plus-chunk\n");
}
+
+ /* That last_t == CHUNK_PLUS indicates to which position on the
+ * left it corresponds, even though it doesn't add any lines on
+ * the left. By inserting/extending the prev_last_t ==
+ * CHUNK_MINUS, that position on the left has shifted. */
+ last = &result->head[result->len - 1];
+ last->left_start = new_chunk->left_start
+ + new_chunk->left_count;
+
} else {
ARRAYLIST_ADD(new_chunk, *result);
if (!new_chunk)