From b65b345011f7aecffef5bc26726d09452a7cbb49 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 19 Feb 2025 09:08:43 +0100 Subject: [PATCH 1/2] Show deprecation message when using legacy snippets --- .../snippetsLegacy/InsertSnippetLegacy.ts | 3 +++ .../snippetsLegacy/WrapWithSnippetLegacy.ts | 3 +++ .../legacySnippetsNotification.ts | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 packages/cursorless-engine/src/actions/snippetsLegacy/legacySnippetsNotification.ts diff --git a/packages/cursorless-engine/src/actions/snippetsLegacy/InsertSnippetLegacy.ts b/packages/cursorless-engine/src/actions/snippetsLegacy/InsertSnippetLegacy.ts index e65b0e34e2..d4b134d06e 100644 --- a/packages/cursorless-engine/src/actions/snippetsLegacy/InsertSnippetLegacy.ts +++ b/packages/cursorless-engine/src/actions/snippetsLegacy/InsertSnippetLegacy.ts @@ -21,6 +21,7 @@ import { findMatchingSnippetDefinitionStrict, transformSnippetVariables, } from "../snippetsLegacy/snippet"; +import { showLegacySnippetsNotification } from "./legacySnippetsNotification"; import { textFormatters, type TextFormatterName } from "./textFormatters"; export default class InsertSnippetLegacy { @@ -95,6 +96,8 @@ export default class InsertSnippetLegacy { destinations: Destination[], snippetDescription: NamedInsertSnippetArg, ): Promise { + showLegacySnippetsNotification(); + const editor = ide().getEditableTextEditor( ensureSingleEditor(destinations), ); diff --git a/packages/cursorless-engine/src/actions/snippetsLegacy/WrapWithSnippetLegacy.ts b/packages/cursorless-engine/src/actions/snippetsLegacy/WrapWithSnippetLegacy.ts index 5e9c4d1dce..99f094c218 100644 --- a/packages/cursorless-engine/src/actions/snippetsLegacy/WrapWithSnippetLegacy.ts +++ b/packages/cursorless-engine/src/actions/snippetsLegacy/WrapWithSnippetLegacy.ts @@ -14,6 +14,7 @@ import { findMatchingSnippetDefinitionStrict, transformSnippetVariables, } from "../snippetsLegacy/snippet"; +import { showLegacySnippetsNotification } from "./legacySnippetsNotification"; export default class WrapWithSnippetLegacy { private snippetParser = new SnippetParser(); @@ -81,6 +82,8 @@ export default class WrapWithSnippetLegacy { targets: Target[], snippetDescription: NamedWrapWithSnippetArg, ): Promise { + showLegacySnippetsNotification(); + const editor = ide().getEditableTextEditor(ensureSingleEditor(targets)); const body = this.getBody(snippetDescription, targets); diff --git a/packages/cursorless-engine/src/actions/snippetsLegacy/legacySnippetsNotification.ts b/packages/cursorless-engine/src/actions/snippetsLegacy/legacySnippetsNotification.ts new file mode 100644 index 0000000000..e8d1467800 --- /dev/null +++ b/packages/cursorless-engine/src/actions/snippetsLegacy/legacySnippetsNotification.ts @@ -0,0 +1,19 @@ +import { showWarning } from "@cursorless/common"; +import { ide } from "../../singletons/ide.singleton"; + +// Show only once per vscode instance +let wasShown = false; + +export function showLegacySnippetsNotification() { + if (wasShown) { + return; + } + + void showWarning( + ide().messages, + "legacySnippets", + "Cursorless snippets are deprecated. Please use community snippets. Update to latest cursorless-talon and say 'cursorless migrate snippets'.", + ); + + wasShown = true; +} From 750c7260a5a4f44611bb7a96978d2b23c537d30a Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 19 Feb 2025 10:20:04 +0100 Subject: [PATCH 2/2] Update packages/cursorless-engine/src/actions/snippetsLegacy/legacySnippetsNotification.ts Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com> --- .../src/actions/snippetsLegacy/legacySnippetsNotification.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cursorless-engine/src/actions/snippetsLegacy/legacySnippetsNotification.ts b/packages/cursorless-engine/src/actions/snippetsLegacy/legacySnippetsNotification.ts index e8d1467800..45873ff07a 100644 --- a/packages/cursorless-engine/src/actions/snippetsLegacy/legacySnippetsNotification.ts +++ b/packages/cursorless-engine/src/actions/snippetsLegacy/legacySnippetsNotification.ts @@ -12,7 +12,7 @@ export function showLegacySnippetsNotification() { void showWarning( ide().messages, "legacySnippets", - "Cursorless snippets are deprecated. Please use community snippets. Update to latest cursorless-talon and say 'cursorless migrate snippets'.", + "Talon community snippets are now fully supported in Cursorless! Cursorless's experimental snippets are now deprecated, but in most cases we can help you migrate automatically. Update cursorless-talon and say 'cursorless migrate snippets'.", ); wasShown = true;