mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 08:44:59 +00:00
aider: Changed self.words
initialization from an empty list to an empty set and replaced the extend
method with the update
method to add words to the set.
# Context: USER: self.words should be a set not a list ASSISTANT: To change `self.words` from a list to a set, we will update the `__init__` method in the `FileContentCompleter` class. Here's the updated code: ```python aider/getinput.py <<<<<<< ORIGINAL class FileContentCompleter(Completer): def __init__(self, fnames): self.words = [] for fname in fnames: with open(fname, "r") as f: content = f.read() self.words.extend(re.split(r'\W+', content)) ======= class FileContentCompleter(Completer): def __init__(self, fnames): self.words = set() for fname in fnames: with open(fname, "r") as f: content = f.read() self.words.update(re.split(r'\W+', content)) >>>>>>> UPDATED ``` This change updates the `self.words` initialization from an empty list to an empty set and replaces the `extend` method with the `update` method to add words to the set.
This commit is contained in:
parent
9c7d308deb
commit
43331aad89
1 changed files with 2 additions and 3 deletions
|
@ -27,12 +27,11 @@ class Commands:
|
|||
|
||||
class FileContentCompleter(Completer):
|
||||
def __init__(self, fnames):
|
||||
self.words = []
|
||||
self.words = set()
|
||||
for fname in fnames:
|
||||
with open(fname, "r") as f:
|
||||
content = f.read()
|
||||
self.words.extend(re.split(r'\W+', content))
|
||||
|
||||
self.words.update(re.split(r'\W+', content))
|
||||
def get_completions(self, document, complete_event):
|
||||
text = document.text_before_cursor
|
||||
words = text.split()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue