Skip to content

Commit 4619cbc

Browse files
Show deprecation message when using legacy snippets (#2857)
Co-authored-by: Pokey Rule <[email protected]>
1 parent 67bab17 commit 4619cbc

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

packages/cursorless-engine/src/actions/snippetsLegacy/InsertSnippetLegacy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
findMatchingSnippetDefinitionStrict,
2222
transformSnippetVariables,
2323
} from "../snippetsLegacy/snippet";
24+
import { showLegacySnippetsNotification } from "./legacySnippetsNotification";
2425
import { textFormatters, type TextFormatterName } from "./textFormatters";
2526

2627
export default class InsertSnippetLegacy {
@@ -95,6 +96,8 @@ export default class InsertSnippetLegacy {
9596
destinations: Destination[],
9697
snippetDescription: NamedInsertSnippetArg,
9798
): Promise<ActionReturnValue> {
99+
showLegacySnippetsNotification();
100+
98101
const editor = ide().getEditableTextEditor(
99102
ensureSingleEditor(destinations),
100103
);

packages/cursorless-engine/src/actions/snippetsLegacy/WrapWithSnippetLegacy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
findMatchingSnippetDefinitionStrict,
1515
transformSnippetVariables,
1616
} from "../snippetsLegacy/snippet";
17+
import { showLegacySnippetsNotification } from "./legacySnippetsNotification";
1718

1819
export default class WrapWithSnippetLegacy {
1920
private snippetParser = new SnippetParser();
@@ -81,6 +82,8 @@ export default class WrapWithSnippetLegacy {
8182
targets: Target[],
8283
snippetDescription: NamedWrapWithSnippetArg,
8384
): Promise<ActionReturnValue> {
85+
showLegacySnippetsNotification();
86+
8487
const editor = ide().getEditableTextEditor(ensureSingleEditor(targets));
8588

8689
const body = this.getBody(snippetDescription, targets);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { showWarning } from "@cursorless/common";
2+
import { ide } from "../../singletons/ide.singleton";
3+
4+
// Show only once per vscode instance
5+
let wasShown = false;
6+
7+
export function showLegacySnippetsNotification() {
8+
if (wasShown) {
9+
return;
10+
}
11+
12+
void showWarning(
13+
ide().messages,
14+
"legacySnippets",
15+
"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'.",
16+
);
17+
18+
wasShown = true;
19+
}

0 commit comments

Comments
 (0)