mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00
fix: Handle case where edit path is None
This commit is contained in:
parent
72bc851ac0
commit
347f3fe140
3 changed files with 22 additions and 8 deletions
|
@ -1731,6 +1731,9 @@ class Coder:
|
|||
|
||||
for edit in edits:
|
||||
path = edit[0]
|
||||
if path is None:
|
||||
res.append(edit)
|
||||
continue
|
||||
if path in seen:
|
||||
allowed = seen[path]
|
||||
else:
|
||||
|
|
|
@ -31,8 +31,10 @@ class EditBlockCoder(Coder):
|
|||
def apply_edits(self, edits):
|
||||
failed = []
|
||||
passed = []
|
||||
|
||||
for edit in edits:
|
||||
if isinstance(edit, str):
|
||||
if edit[0] is None:
|
||||
edit = edit[1]
|
||||
# This is a shell command
|
||||
self.io.tool_output(f"Shell command: {edit}")
|
||||
if self.io.confirm_ask("Do you want to run this command?"):
|
||||
|
@ -413,9 +415,18 @@ def find_original_update_blocks(content, fence=DEFAULT_FENCE):
|
|||
|
||||
# Check for shell code blocks
|
||||
shell_starts = [
|
||||
"```bash", "```sh", "```shell", "```cmd", "```batch",
|
||||
"```powershell", "```ps1", "```zsh", "```fish", "```ksh",
|
||||
"```csh", "```tcsh"
|
||||
"```bash",
|
||||
"```sh",
|
||||
"```shell",
|
||||
"```cmd",
|
||||
"```batch",
|
||||
"```powershell",
|
||||
"```ps1",
|
||||
"```zsh",
|
||||
"```fish",
|
||||
"```ksh",
|
||||
"```csh",
|
||||
"```tcsh",
|
||||
]
|
||||
if any(line.strip().startswith(start) for start in shell_starts):
|
||||
shell_type = line.strip().split("```")[1]
|
||||
|
@ -426,13 +437,13 @@ def find_original_update_blocks(content, fence=DEFAULT_FENCE):
|
|||
i += 1
|
||||
if i < len(lines) and lines[i].strip().startswith("```"):
|
||||
i += 1 # Skip the closing ```
|
||||
yield f"{shell_type}_command", "".join(shell_content)
|
||||
yield None, "".join(shell_content)
|
||||
continue
|
||||
|
||||
# Check for SEARCH/REPLACE blocks
|
||||
if line.strip() == HEAD:
|
||||
try:
|
||||
filename = find_filename(lines[max(0, i-3):i], fence)
|
||||
filename = find_filename(lines[max(0, i - 3) : i], fence)
|
||||
if not filename:
|
||||
if current_filename:
|
||||
filename = current_filename
|
||||
|
@ -462,7 +473,7 @@ def find_original_update_blocks(content, fence=DEFAULT_FENCE):
|
|||
yield filename, "".join(original_text), "".join(updated_text)
|
||||
|
||||
except ValueError as e:
|
||||
processed = "".join(lines[:i+1])
|
||||
processed = "".join(lines[: i + 1])
|
||||
err = e.args[0]
|
||||
raise ValueError(f"{processed}\n^^^ {err}")
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ Once you understand the request you MUST:
|
|||
1. Decide if you need to propose *SEARCH/REPLACE* edits to any files that haven't been added to the chat. You can create new files without asking. But if you need to propose edits to existing files not already added to the chat, you *MUST* tell the user their full path names and ask them to *add the files to the chat*. End your reply and wait for their approval. You can keep asking if you then decide you need to edit more files.
|
||||
2. Think step-by-step and explain the needed changes with a numbered list of short sentences.
|
||||
3. Describe each change with a *SEARCH/REPLACE block* per the examples below. All changes to files must use this *SEARCH/REPLACE block* format. ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*!
|
||||
4. *Briefly* and *concisely* suggest any shell commands the user might want to run, like:
|
||||
4. *Concisely* suggest any shell commands the user might want to run like in ```bash blocks (or appropriate shell):
|
||||
- If you changed a self-contained html file, suggest an OS-appropriate command to open a browser to view it to see the updated content.
|
||||
- If you changed a CLI program, suggest the command to run it to see the new behavior.
|
||||
- If you added a test, suggest how to run it with the project's testing tool.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue