From 67121a9834992fd2a22ce0958153923c3b4d4a8e Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 5 Jun 2023 16:47:52 -0700 Subject: [PATCH] aider: Added function to print unified diff and find last non-deleted line. # Context: USER: do the todo --- aider/diffs.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/aider/diffs.py b/aider/diffs.py index bde25ee5f..fda2e47d1 100644 --- a/aider/diffs.py +++ b/aider/diffs.py @@ -17,6 +17,12 @@ def main(): with open(file_updated, "r") as f: lines_updated = f.readlines() + unified_diff = difflib.unified_diff(lines_orig, lines_updated, fromfile=file_orig, tofile=file_updated) + for line in unified_diff: + print(line, end="") + +def find_last_non_deleted(lines_orig, lines_updated): + diff = list(difflib.ndiff(lines_orig, lines_updated)) num_orig = 0