From 1b726566186498ed7a76dd85f1e00625223b71ad Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 8 May 2023 09:18:14 -0700 Subject: [PATCH] Tighter regex to find the filename --- coder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coder.py b/coder.py index 0a6a4174e..d376ae213 100755 --- a/coder.py +++ b/coder.py @@ -303,14 +303,14 @@ class Coder: self.console.print(md) pattern = re.compile( - r"(\S+)\s+(```\s*)?<<<<<<< ORIGINAL\n(.*?\n?)=======\n(.*?\n?)>>>>>>> UPDATED", + r"(^```\S*\s*)?^((?:[a-zA-Z]:\\|/)?(?:[\w\s.-]+[\\/])*\w+\.\w+)\s+(^```\S*\s*)?^<<<<<<< ORIGINAL\n(.*?\n?)^=======\n(.*?\n?)*^>>>>>>> UPDATED", # noqa: E501 re.MULTILINE | re.DOTALL, ) def update_files(self, content, inp): edited = set() for match in self.pattern.finditer(content): - path, _, original, updated = match.groups() + _, path, _, original, updated = match.groups() edited.add(path) if self.do_replace(path, original, updated):