From 3f949e63a0d1527893d2926eb094f8fc45c851f2 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 9 May 2023 17:53:29 -0700 Subject: [PATCH] aider: Updated FileContentCompleter to split files into words on non-alphanums. # Context: USER: have FileContentCompleter(Completer) split the files into words on non-alphanums. so each word is a contiguous sequence of alphanums. non-alphanums are ignored, and only used to split. ASSISTANT: To achieve this, you can update the regular expression used in the `re.split()` function inside the `FileContentCompleter` class. You can use the `\W+` pattern to split the content based on non-alphanumeric characters. Here's the change: ```python aider/getinput.py <<<<<<< ORIGINAL for word in re.split(r"\W+", content): ======= for word in re.split(r'\W+', content): >>>>>>> UPDATED ``` This change will ensure that the content is split into words based on non-alphanumeric characters, and each word will be a contiguous sequence of alphanumerics. --- aider/getinput.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aider/getinput.py b/aider/getinput.py index 76315146e..85bc4fb11 100644 --- a/aider/getinput.py +++ b/aider/getinput.py @@ -26,7 +26,7 @@ class FileContentCompleter(Completer): with open(fname, "r") as f: content = f.read() - for word in re.split(r"\W+", content): + for word in re.split(r'\W+', content): if word.startswith(last_word): yield Completion(word, start_position=-len(last_word))