From f2e01f3b391ece42cec6b260260ed314e15ba298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Sun, 22 Dec 2024 14:52:43 +0100 Subject: [PATCH] fix: prettier /command completions --- gptme/util/prompt.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gptme/util/prompt.py b/gptme/util/prompt.py index e05de52e..fcfe5efc 100644 --- a/gptme/util/prompt.py +++ b/gptme/util/prompt.py @@ -315,15 +315,18 @@ def get_completions(self, document, complete_event): text = document.text_before_cursor path_seg = text.split(" ")[-1] + completions = [f"/{cmd}" for cmd in COMMANDS] + # Command completion if text.startswith("/"): - cmd_text = text[1:] - for cmd in COMMANDS: - if cmd.startswith(cmd_text): + for option in completions: + if option.startswith(text): + # make the already typed part bold and underlined + html = f"{text}{option[len(text):]}" yield Completion( - cmd, - start_position=-len(cmd_text), - display=HTML(f"/{cmd}"), + option, + start_position=-len(text), + display=HTML(html), ) # Path completion