fix(diff): myers now also strdups the line of the file on insert action when taking the diff
This commit is contained in:
parent
252bdc281e
commit
1e3934cf20
1 changed files with 3 additions and 1 deletions
|
|
@ -78,12 +78,14 @@ ActionList* myers_diff(File* old_version, File* new_version, uint64_t old_offset
|
||||||
temp_actions[temp_count].type = INSERT;
|
temp_actions[temp_count].type = INSERT;
|
||||||
temp_actions[temp_count].line_original = old_offset + i;
|
temp_actions[temp_count].line_original = old_offset + i;
|
||||||
temp_actions[temp_count].line_changed = new_offset + j - 1;
|
temp_actions[temp_count].line_changed = new_offset + j - 1;
|
||||||
|
temp_actions[temp_count].content = strdup(new_version->content[j - 1]); // Copy the content for INSERT action
|
||||||
temp_count++;
|
temp_count++;
|
||||||
j--;
|
j--;
|
||||||
} else if (i > 0) {
|
} else if (i > 0) {
|
||||||
temp_actions[temp_count].type = DELETE;
|
temp_actions[temp_count].type = DELETE;
|
||||||
temp_actions[temp_count].line_original = old_offset + i - 1;
|
temp_actions[temp_count].line_original = old_offset + i - 1;
|
||||||
temp_actions[temp_count].line_changed = 0;
|
temp_actions[temp_count].line_changed = 0;
|
||||||
|
temp_actions[temp_count].content = NULL; // No content for DELETE action
|
||||||
temp_count++;
|
temp_count++;
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue