File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 2020from .log import log_error
2121from .settings import get_plugin_setting_dotted
2222from .types import (
23+ CopilotConversationTemplates ,
2324 CopilotDocType ,
2425 CopilotPayloadCompletion ,
2526 CopilotPayloadPanelSolution ,
@@ -284,10 +285,8 @@ def preprocess_chat_message(
284285
285286 templates = templates or []
286287 user_template = first_true (templates , pred = lambda t : f"/{ t ['id' ]} " == message )
287- is_template = False
288288
289- if user_template :
290- is_template = True
289+ if is_template := bool (user_template or CopilotConversationTemplates .has_value (message )):
291290 message += "\n \n {{ user_prompt }}\n \n {{ code }}"
292291
293292 region = view .sel ()[0 ]
Original file line number Diff line number Diff line change @@ -163,6 +163,14 @@ class CopilotConversationTemplates(StrEnum):
163163 EXPLAIN = "/explain"
164164 SIMPLIFY = "/simplify"
165165
166+ @classmethod
167+ def has_value (cls , value : str ) -> bool :
168+ try :
169+ cls (value )
170+ return True
171+ except ValueError :
172+ return False
173+
166174
167175class CopilotPayloadConversationEntry (TypedDict , total = True ):
168176 kind : str
You can’t perform that action at this time.
0 commit comments