mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-06 04:35:00 +00:00
handle diff output for new file
This commit is contained in:
parent
93d4fe5f14
commit
552bdc4f71
1 changed files with 14 additions and 9 deletions
|
@ -55,15 +55,18 @@ class WholeFileCoder(Coder):
|
||||||
|
|
||||||
full_path = (Path(self.root) / fname).absolute()
|
full_path = (Path(self.root) / fname).absolute()
|
||||||
|
|
||||||
if mode == "diff" and full_path.exists():
|
if mode == "diff":
|
||||||
orig_lines = self.io.read_text(full_path).splitlines(keepends=True)
|
if full_path.exists():
|
||||||
|
orig_lines = self.io.read_text(full_path).splitlines(keepends=True)
|
||||||
|
|
||||||
show_diff = diffs.diff_partial_update(
|
show_diff = diffs.diff_partial_update(
|
||||||
orig_lines,
|
orig_lines,
|
||||||
new_lines,
|
new_lines,
|
||||||
final=True,
|
final=True,
|
||||||
).splitlines()
|
).splitlines()
|
||||||
output += show_diff
|
output += show_diff
|
||||||
|
else:
|
||||||
|
output += ["```"] + new_lines + ["```"]
|
||||||
else:
|
else:
|
||||||
if self.allowed_to_edit(fname):
|
if self.allowed_to_edit(fname):
|
||||||
edited.add(fname)
|
edited.add(fname)
|
||||||
|
@ -110,7 +113,7 @@ class WholeFileCoder(Coder):
|
||||||
# ending an existing block
|
# ending an existing block
|
||||||
full_path = (Path(self.root) / fname).absolute()
|
full_path = (Path(self.root) / fname).absolute()
|
||||||
|
|
||||||
if mode == "diff" and full_path.exists():
|
if full_path.exists():
|
||||||
orig_lines = self.io.read_text(full_path).splitlines(keepends=True)
|
orig_lines = self.io.read_text(full_path).splitlines(keepends=True)
|
||||||
|
|
||||||
show_diff = diffs.diff_partial_update(
|
show_diff = diffs.diff_partial_update(
|
||||||
|
@ -118,6 +121,8 @@ class WholeFileCoder(Coder):
|
||||||
new_lines,
|
new_lines,
|
||||||
).splitlines()
|
).splitlines()
|
||||||
output += show_diff
|
output += show_diff
|
||||||
|
else:
|
||||||
|
output += ["```"] + new_lines + ["```"]
|
||||||
|
|
||||||
return "\n".join(output)
|
return "\n".join(output)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue