From be1b37c3a18e98a4fb3e1003847f7a723d36bfce Mon Sep 17 00:00:00 2001 From: Nicholas Riley Date: Sat, 14 Jun 2025 14:16:53 -0400 Subject: [PATCH] Allow snippet insertion with a language unsupported by VSCode --- cursorless-talon/src/snippets/snippets.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cursorless-talon/src/snippets/snippets.py b/cursorless-talon/src/snippets/snippets.py index 0bd0982608..1d054c7e5a 100644 --- a/cursorless-talon/src/snippets/snippets.py +++ b/cursorless-talon/src/snippets/snippets.py @@ -106,7 +106,17 @@ def insert_snippet_by_name( get_list_insertion_snippet(name, substitutions), ImplicitDestination(), ) - actions.user.private_cursorless_command_and_wait(action) + try: + actions.user.private_cursorless_command_and_wait(action) + except Exception as e: + if str(e).startswith("No snippet available for language"): + action = InsertSnippetAction( + get_insertion_snippet(name, substitutions), + ImplicitDestination(), + ) + actions.user.private_cursorless_command_and_wait(action) + else: + raise def private_cursorless_insert_community_snippet( name: str, # pyright: ignore [reportGeneralTypeIssues]