feat: Add document and complete_event parameters to get_command_completions

This commit is contained in:
Paul Gauthier (aider) 2024-09-27 16:04:17 -07:00
parent 3ec0861727
commit 6c2c3942bf

View file

@ -93,7 +93,7 @@ class AutoCompleter(Completer):
(token[1], f"`{token[1]}`") for token in tokens if token[0] in Token.Name (token[1], f"`{token[1]}`") for token in tokens if token[0] in Token.Name
) )
def get_command_completions(self, text, words): def get_command_completions(self, document, complete_event, text, words):
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)]
@ -115,8 +115,7 @@ class AutoCompleter(Completer):
raw_completer = self.commands.get_raw_completions(cmd) raw_completer = self.commands.get_raw_completions(cmd)
if raw_completer: if raw_completer:
for comp in raw_completer(document, complete_event): yield from raw_completer(document, complete_event)
yield comp
return return
if cmd not in self.command_completions: if cmd not in self.command_completions:
@ -145,7 +144,7 @@ class AutoCompleter(Completer):
return return
if text[0] == "/": if text[0] == "/":
yield from self.get_command_completions(text, words) yield from self.get_command_completions(document, complete_event, text, words)
return return
candidates = self.words candidates = self.words