This commit is contained in:
Paul Gauthier 2023-06-05 21:37:56 -07:00
parent 2336af2886
commit 6081baa32b
2 changed files with 5 additions and 1 deletions

View file

@ -500,6 +500,7 @@ class Coder:
show_diff = diffs.diff_partial_update( show_diff = diffs.diff_partial_update(
orig_lines, orig_lines,
new_lines, new_lines,
final=True,
).splitlines() ).splitlines()
output += show_diff output += show_diff
else: else:

View file

@ -23,7 +23,7 @@ def main():
input() input()
def diff_partial_update(lines_orig, lines_updated): def diff_partial_update(lines_orig, lines_updated, final=False):
""" """
Given only the first part of an updated file, show the diff while Given only the first part of an updated file, show the diff while
ignoring the block of "deleted" lines that are past the end of the ignoring the block of "deleted" lines that are past the end of the
@ -40,6 +40,9 @@ def diff_partial_update(lines_orig, lines_updated):
lines_orig = lines_orig[:last_non_deleted] lines_orig = lines_orig[:last_non_deleted]
if not final:
lines_updated = lines_updated[:-1] + ["\n"]
diff = difflib.unified_diff(lines_orig, lines_updated) diff = difflib.unified_diff(lines_orig, lines_updated)
# unified_diff = list(unified_diff)[2:] # unified_diff = list(unified_diff)[2:]
# dump(repr(list(diff))) # dump(repr(list(diff)))