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.
This commit is contained in:
Paul Gauthier 2023-05-09 17:53:29 -07:00
parent 3425adee28
commit 3f949e63a0

View file

@ -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))