mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 06:15:00 +00:00
WIP: Added find_block function to coder.py.
This commit is contained in:
parent
6175d05979
commit
ecdbc762d9
1 changed files with 4 additions and 11 deletions
15
coder.py
15
coder.py
|
@ -18,6 +18,7 @@ from rich.markdown import Markdown
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from findblock import find_block
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import git
|
import git
|
||||||
|
@ -36,13 +37,6 @@ except FileNotFoundError:
|
||||||
openai.api_key = os.getenv("OPENAI_API_KEY")
|
openai.api_key = os.getenv("OPENAI_API_KEY")
|
||||||
|
|
||||||
|
|
||||||
def find_index(list1, list2):
|
|
||||||
for i in range(len(list1)):
|
|
||||||
if list1[i : i + len(list2)] == list2:
|
|
||||||
return i
|
|
||||||
return -1
|
|
||||||
|
|
||||||
|
|
||||||
class Coder:
|
class Coder:
|
||||||
fnames = dict()
|
fnames = dict()
|
||||||
last_modified = 0
|
last_modified = 0
|
||||||
|
@ -271,7 +265,7 @@ class Coder:
|
||||||
message=commit_message,
|
message=commit_message,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.console.print("[red bold]Edits failed to change the files?")
|
self.console.print("[red bold]No changes found in tracked files.")
|
||||||
saved_message = prompts.files_content_gpt_no_edits
|
saved_message = prompts.files_content_gpt_no_edits
|
||||||
|
|
||||||
self.check_for_local_edits(True)
|
self.check_for_local_edits(True)
|
||||||
|
@ -429,9 +423,8 @@ class Coder:
|
||||||
# first populating an empty file
|
# first populating an empty file
|
||||||
new_content = after_text
|
new_content = after_text
|
||||||
else:
|
else:
|
||||||
before_lines = [line.strip() for line in before_text.splitlines()]
|
before_lines = before_text.splitlines()
|
||||||
stripped_content = [line.strip() for line in content]
|
where = find_block(content, before_lines)
|
||||||
where = find_index(stripped_content, before_lines)
|
|
||||||
|
|
||||||
if where < 0:
|
if where < 0:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue