mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-09 06:05:00 +00:00
stronger wholefile prompt about file listings; adopt allowed_to_edit in wholefile; tests
This commit is contained in:
parent
d00e7c39d1
commit
eaf02da46b
4 changed files with 50 additions and 12 deletions
|
@ -28,14 +28,12 @@ class WholeFileCoder(Coder):
|
|||
|
||||
edited = set()
|
||||
chat_files = self.get_inchat_relative_files()
|
||||
if not chat_files:
|
||||
if mode == "diff":
|
||||
return content
|
||||
return
|
||||
|
||||
output = []
|
||||
lines = content.splitlines(keepends=True)
|
||||
|
||||
allowed_to_edit = False
|
||||
|
||||
fname = None
|
||||
new_lines = []
|
||||
for i, line in enumerate(lines):
|
||||
|
@ -55,10 +53,11 @@ class WholeFileCoder(Coder):
|
|||
).splitlines()
|
||||
output += show_diff
|
||||
else:
|
||||
edited.add(fname)
|
||||
if not self.dry_run:
|
||||
new_lines = "".join(new_lines)
|
||||
Path(full_path).write_text(new_lines)
|
||||
if allowed_to_edit:
|
||||
edited.add(fname)
|
||||
if not self.dry_run:
|
||||
new_lines = "".join(new_lines)
|
||||
Path(full_path).write_text(new_lines)
|
||||
|
||||
fname = None
|
||||
new_lines = []
|
||||
|
@ -74,8 +73,11 @@ class WholeFileCoder(Coder):
|
|||
else:
|
||||
fname = lines[i - 1].strip()
|
||||
|
||||
if mode == "update" and not self.allowed_to_edit(fname):
|
||||
raise ValueError(f"{fname} is not one of: {show_chat_files}")
|
||||
if mode == "update":
|
||||
if self.allowed_to_edit(fname):
|
||||
allowed_to_edit = True
|
||||
else:
|
||||
allowed_to_edit = False
|
||||
|
||||
elif fname:
|
||||
new_lines.append(line)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue