Skip to content

Commit

Permalink
fix: prettier /command completions
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Dec 22, 2024
1 parent 7ff8492 commit f2e01f3
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions gptme/util/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"<teal><u><b>{text}</b></u>{option[len(text):]}</teal>"
yield Completion(
cmd,
start_position=-len(cmd_text),
display=HTML(f"<blue>/{cmd}</blue>"),
option,
start_position=-len(text),
display=HTML(html),
)

# Path completion
Expand Down

0 comments on commit f2e01f3

Please sign in to comment.