Skip to content

Commit 415945a

Browse files
More snippet cleanup
1 parent 7f5d4f6 commit 415945a

File tree

5 files changed

+15
-81
lines changed

5 files changed

+15
-81
lines changed

cursorless-talon-dev/src/spoken_form_test.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939

4040
mockedGetValue = ""
4141

42-
community_snippets_tag_name = "user.cursorless_use_community_snippets"
43-
4442

4543
@ctx.action_class("user")
4644
class UserActions:
@@ -99,20 +97,6 @@ def private_cursorless_spoken_form_test_mode(enable: bool): # pyright: ignore [
9997
"Cursorless spoken form tests are done. Talon microphone is re-enabled."
10098
)
10199

102-
def private_cursorless_use_community_snippets(enable: bool): # pyright: ignore [reportGeneralTypeIssues]
103-
"""Enable/disable cursorless community snippets in test mode"""
104-
if enable:
105-
tags = set(ctx.tags)
106-
tags.add(community_snippets_tag_name)
107-
ctx.tags = list(tags)
108-
else:
109-
tags = set(ctx.tags)
110-
tags.remove(community_snippets_tag_name)
111-
ctx.tags = list(tags)
112-
# Note: Test harness hangs if we don't print anything because it's
113-
# waiting for stdout
114-
print(f"Set community snippet enablement to {enable}")
115-
116100
def private_cursorless_spoken_form_test(
117101
phrase: str, # pyright: ignore [reportGeneralTypeIssues]
118102
mockedGetValue_: Optional[str],

cursorless-talon/src/actions/generate_snippet.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import glob
22
from pathlib import Path
33

4-
from talon import Context, Module, actions, registry, settings
4+
from talon import Module, actions, registry, settings
55

66
from ..targets.target_types import CursorlessExplicitTarget
77

88
mod = Module()
99

10-
ctx = Context()
11-
ctx.matches = r"""
12-
tag: user.cursorless_use_community_snippets
13-
"""
14-
1510

1611
@mod.action_class
1712
class Actions:
@@ -33,17 +28,6 @@ def private_cursorless_migrate_snippets():
3328

3429
def private_cursorless_generate_snippet_action(target: CursorlessExplicitTarget): # pyright: ignore [reportGeneralTypeIssues]
3530
"""Generate a snippet from the given target"""
36-
actions.user.private_cursorless_command_no_wait(
37-
{
38-
"name": "generateSnippet",
39-
"target": target,
40-
}
41-
)
42-
43-
44-
@ctx.action_class("user")
45-
class UserActions:
46-
def private_cursorless_generate_snippet_action(target: CursorlessExplicitTarget): # pyright: ignore [reportGeneralTypeIssues]
4731
actions.user.private_cursorless_command_no_wait(
4832
{
4933
"name": "generateSnippet",

packages/cursorless-engine/src/test/fixtures/communitySnippets.fixture.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,5 @@ const verticalRangeAction: ActionDescriptor = {
2727
* Talon tests by relying on our recorded test fixtures alone.
2828
*/
2929
export const communitySnippetsSpokenFormsFixture = [
30-
spokenFormTest("snippet code after air", verticalRangeAction, undefined, {
31-
useCommunitySnippets: true,
32-
}),
30+
spokenFormTest("snippet code after air", verticalRangeAction, undefined),
3331
];

packages/cursorless-engine/src/test/fixtures/spokenFormTest.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,29 @@ export interface SpokenFormTest {
2323
* {@link spokenForm} is spoken.
2424
*/
2525
commands: CommandV6[];
26-
27-
/**
28-
* If `true`, use community snippets instead of Cursorless snippets
29-
*/
30-
useCommunitySnippets: boolean;
3126
}
3227

3328
export function spokenFormTest(
3429
spokenForm: string,
3530
action: ActionDescriptor,
3631
mockedGetValue?: unknown,
37-
{ useCommunitySnippets = false }: SpokenFormTestOpts = {},
3832
): SpokenFormTest {
3933
return {
4034
spokenForm,
4135
mockedGetValue: wrapMockedGetValue(mockedGetValue),
4236
commands: [command(spokenForm, action)],
43-
useCommunitySnippets,
4437
};
4538
}
4639

4740
export function multiActionSpokenFormTest(
4841
spokenForm: string,
4942
actions: ActionDescriptor[],
5043
mockedGetValue?: unknown,
51-
{ useCommunitySnippets = false }: SpokenFormTestOpts = {},
5244
): SpokenFormTest {
5345
return {
5446
spokenForm,
5547
mockedGetValue: wrapMockedGetValue(mockedGetValue),
5648
commands: actions.map((action) => command(spokenForm, action)),
57-
useCommunitySnippets,
5849
};
5950
}
6051

@@ -72,7 +63,3 @@ function command(spokenForm: string, action: ActionDescriptor): CommandV6 {
7263
action,
7364
};
7465
}
75-
76-
export interface SpokenFormTestOpts {
77-
useCommunitySnippets?: boolean;
78-
}

packages/cursorless-engine/src/test/spokenForms.talon.test.ts

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { getHatMapCommand } from "../generateSpokenForm/getHatMapCommand";
1313
import { TalonRepl } from "../testUtil/TalonRepl";
1414
import { communitySnippetsSpokenFormsFixture } from "./fixtures/communitySnippets.fixture";
1515
import { multiActionFixture } from "./fixtures/multiAction.fixture";
16-
import type { SpokenFormTestOpts } from "./fixtures/spokenFormTest";
1716
import { synonymousSpokenFormsFixture } from "./fixtures/synonymousSpokenForms.fixture";
1817
import { talonApiFixture } from "./fixtures/talonApi.fixture";
1918

@@ -45,12 +44,8 @@ suite("Talon spoken forms", async function () {
4544
...talonApiFixture,
4645
...multiActionFixture,
4746
...communitySnippetsSpokenFormsFixture,
48-
].forEach(({ spokenForm, commands, mockedGetValue, useCommunitySnippets }) =>
49-
test(spokenForm, () =>
50-
runTest(repl, spokenForm, commands, mockedGetValue, {
51-
useCommunitySnippets,
52-
}),
53-
),
47+
].forEach(({ spokenForm, commands, mockedGetValue }) =>
48+
test(spokenForm, () => runTest(repl, spokenForm, commands, mockedGetValue)),
5449
);
5550
});
5651

@@ -83,7 +78,6 @@ async function runTest(
8378
spokenForm: string,
8479
commandsLegacy: Command[],
8580
mockedGetValue?: unknown,
86-
{ useCommunitySnippets = false }: SpokenFormTestOpts = {},
8781
) {
8882
const commandsExpected = commandsLegacy.map((command) => ({
8983
...canonicalizeAndValidateCommand(command),
@@ -109,37 +103,24 @@ async function runTest(
109103
? "None"
110104
: JSON.stringify(JSON.stringify(mockedGetValue));
111105

112-
if (useCommunitySnippets) {
113-
await repl.action(`user.private_cursorless_use_community_snippets(True)`);
114-
}
106+
const result = await repl.action(
107+
`user.private_cursorless_spoken_form_test("${spokenForm}", ${mockedGetValueString})`,
108+
);
115109

116-
try {
117-
const result = await repl.action(
118-
`user.private_cursorless_spoken_form_test("${spokenForm}", ${mockedGetValueString})`,
119-
);
120-
121-
const commandsActual = (() => {
122-
try {
123-
return JSON.parse(result);
124-
} catch (_e) {
125-
throw Error(result);
126-
}
127-
})();
128-
129-
assert.deepStrictEqual(commandsActual, commandsExpected);
130-
} finally {
131-
if (useCommunitySnippets) {
132-
await repl.action(
133-
`user.private_cursorless_use_community_snippets(False)`,
134-
);
110+
const commandsActual = (() => {
111+
try {
112+
return JSON.parse(result);
113+
} catch (_e) {
114+
throw Error(result);
135115
}
136-
}
116+
})();
117+
118+
assert.deepStrictEqual(commandsActual, commandsExpected);
137119
}
138120

139121
async function setTestMode(repl: TalonRepl, enabled: boolean) {
140122
const arg = enabled ? "True" : "False";
141123
await repl.action(`user.private_cursorless_spoken_form_test_mode(${arg})`);
142-
await repl.action(`user.private_cursorless_use_community_snippets(False)`);
143124

144125
// If you have warnings in your talon user files, they will be printed to the
145126
// repl when you run the above action. We need to eat them so that they don't

0 commit comments

Comments
 (0)