From ecdbc762d9a8d3daef5ed7a17d403707bc2d7f7c Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 8 May 2023 22:06:50 -0700 Subject: [PATCH] WIP: Added find_block function to coder.py. --- coder.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/coder.py b/coder.py index 51ab7d85e..e94007506 100755 --- a/coder.py +++ b/coder.py @@ -18,6 +18,7 @@ from rich.markdown import Markdown from tqdm import tqdm from pathlib import Path +from findblock import find_block import os import git @@ -36,13 +37,6 @@ except FileNotFoundError: 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: fnames = dict() last_modified = 0 @@ -271,7 +265,7 @@ class Coder: message=commit_message, ) 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 self.check_for_local_edits(True) @@ -429,9 +423,8 @@ class Coder: # first populating an empty file new_content = after_text else: - before_lines = [line.strip() for line in before_text.splitlines()] - stripped_content = [line.strip() for line in content] - where = find_index(stripped_content, before_lines) + before_lines = before_text.splitlines() + where = find_block(content, before_lines) if where < 0: return