From 43331aad89ae9d1c9af6a0f06c5b9e8ef4b1eebe Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 10 May 2023 10:55:39 -0700 Subject: [PATCH] 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. --- aider/getinput.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/aider/getinput.py b/aider/getinput.py index 08e4af03a..60fa8f01f 100644 --- a/aider/getinput.py +++ b/aider/getinput.py @@ -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()