Skip to content

Commit

Permalink
fix: /explain (and others) doesn't work (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfcherng authored Aug 13, 2024
1 parent 31b5bc1 commit 575b255
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 2 additions & 3 deletions plugin/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from .log import log_error
from .settings import get_plugin_setting_dotted
from .types import (
CopilotConversationTemplates,
CopilotDocType,
CopilotPayloadCompletion,
CopilotPayloadPanelSolution,
Expand Down Expand Up @@ -284,10 +285,8 @@ def preprocess_chat_message(

templates = templates or []
user_template = first_true(templates, pred=lambda t: f"/{t['id']}" == message)
is_template = False

if user_template:
is_template = True
if is_template := bool(user_template or CopilotConversationTemplates.has_value(message)):
message += "\n\n{{ user_prompt }}\n\n{{ code }}"

region = view.sel()[0]
Expand Down
8 changes: 8 additions & 0 deletions plugin/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ class CopilotConversationTemplates(StrEnum):
EXPLAIN = "/explain"
SIMPLIFY = "/simplify"

@classmethod
def has_value(cls, value: str) -> bool:
try:
cls(value)
return True
except ValueError:
return False


class CopilotPayloadConversationEntry(TypedDict, total=True):
kind: str
Expand Down

0 comments on commit 575b255

Please sign in to comment.