mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-05 12:14:59 +00:00
feat: Update get_command_completions and get_completions methods
This commit is contained in:
parent
01437fa58c
commit
37b512e4fc
1 changed files with 9 additions and 12 deletions
21
aider/io.py
21
aider/io.py
|
@ -94,16 +94,15 @@ class AutoCompleter(Completer):
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_command_completions(self, text, words):
|
def get_command_completions(self, text, words):
|
||||||
candidates = []
|
|
||||||
if len(words) == 1 and not text[-1].isspace():
|
if len(words) == 1 and not text[-1].isspace():
|
||||||
partial = words[0].lower()
|
partial = words[0].lower()
|
||||||
candidates = [cmd for cmd in self.command_names if cmd.startswith(partial)]
|
candidates = [cmd for cmd in self.command_names if cmd.startswith(partial)]
|
||||||
return candidates
|
for candidate in sorted(candidates):
|
||||||
|
yield Completion(candidate, start_position=-len(words[-1]))
|
||||||
|
return
|
||||||
|
|
||||||
if len(words) <= 1:
|
if len(words) <= 1 or text[-1].isspace():
|
||||||
return []
|
return
|
||||||
if text[-1].isspace():
|
|
||||||
return []
|
|
||||||
|
|
||||||
cmd = words[0]
|
cmd = words[0]
|
||||||
partial = words[-1].lower()
|
partial = words[-1].lower()
|
||||||
|
@ -124,7 +123,8 @@ class AutoCompleter(Completer):
|
||||||
return
|
return
|
||||||
|
|
||||||
candidates = [word for word in candidates if partial in word.lower()]
|
candidates = [word for word in candidates if partial in word.lower()]
|
||||||
return candidates
|
for candidate in sorted(candidates):
|
||||||
|
yield Completion(candidate, start_position=-len(words[-1]))
|
||||||
|
|
||||||
def get_completions(self, document, complete_event):
|
def get_completions(self, document, complete_event):
|
||||||
self.tokenize()
|
self.tokenize()
|
||||||
|
@ -139,11 +139,8 @@ class AutoCompleter(Completer):
|
||||||
return
|
return
|
||||||
|
|
||||||
if text[0] == "/":
|
if text[0] == "/":
|
||||||
candidates = self.get_command_completions(text, words)
|
yield from self.get_command_completions(text, words)
|
||||||
if candidates is not None:
|
return
|
||||||
for candidate in sorted(candidates):
|
|
||||||
yield Completion(candidate, start_position=-len(words[-1]))
|
|
||||||
return
|
|
||||||
|
|
||||||
candidates = self.words
|
candidates = self.words
|
||||||
candidates.update(set(self.fname_to_rel_fnames))
|
candidates.update(set(self.fname_to_rel_fnames))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue