Skip to content

Commit 85ce0c7

Browse files
authored
add cursorless record one and cursorless record silent (#1688)
See each commit for more details as desired. - add cursorless record one command - add "cursorless record silent" spoken form ## Checklist - [/] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet
1 parent 948bc12 commit 85ce0c7

File tree

6 files changed

+34
-0
lines changed

6 files changed

+34
-0
lines changed

cursorless-talon-dev/src/cursorless_dev.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ def cursorless_record_that_mark_test():
2828
actions.user.run_rpc_command(
2929
"cursorless.recordTestCase", {"captureFinalThatMark": True}
3030
)
31+
32+
def cursorless_record_silent_test():
33+
"""Start recording Cursorless tests, without confirmation popup windows"""
34+
actions.user.run_rpc_command("cursorless.recordTestCase", {"isSilent": True})

cursorless-talon-dev/src/cursorless_dev.talon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ tag: user.cursorless
33

44
{user.cursorless_homophone} record:
55
user.run_rpc_command("cursorless.recordTestCase")
6+
{user.cursorless_homophone} record one:
7+
user.run_rpc_command("cursorless.recordOneTestCaseThenPause")
68
{user.cursorless_homophone} pause:
79
user.run_rpc_command("cursorless.pauseRecording")
810
{user.cursorless_homophone} resume:
@@ -15,6 +17,7 @@ tag: user.cursorless
1517
user.cursorless_record_highlights_test()
1618
{user.cursorless_homophone} record that mark:
1719
user.cursorless_record_that_mark_test()
20+
{user.cursorless_homophone} record silent: user.cursorless_record_silent_test()
1821

1922
{user.cursorless_homophone} update cheatsheet:
2023
user.cursorless_cheat_sheet_update_json()

packages/common/src/cursorlessCommandIds.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const cursorlessCommandIds = [
3737
"cursorless.pauseRecording",
3838
"cursorless.recomputeDecorationStyles",
3939
"cursorless.recordTestCase",
40+
"cursorless.recordOneTestCaseThenPause",
4041
"cursorless.resumeRecording",
4142
"cursorless.showCheatsheet",
4243
"cursorless.showDocumentation",
@@ -58,6 +59,9 @@ export const cursorlessCommandDescriptions: Record<
5859
"Recompute decoration styles",
5960
),
6061
["cursorless.recordTestCase"]: new VisibleCommand("Record test case"),
62+
["cursorless.recordOneTestCaseThenPause"]: new VisibleCommand(
63+
"Record one test case, then pause",
64+
),
6165
["cursorless.pauseRecording"]: new VisibleCommand(
6266
"Pause test case recording",
6367
),

packages/cursorless-engine/src/testCaseRecorder/TestCaseRecorder.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ const TIMING_CALIBRATION_HIGHLIGHT_ID = "timingCalibration";
8989
*/
9090
export class TestCaseRecorder {
9191
private active: boolean = false;
92+
private pauseAfterNextCommand: boolean = false;
9293
private fixtureRoot: string | null;
9394
private targetDirectory: string | null = null;
9495
private testCase: TestCase | null = null;
@@ -117,6 +118,7 @@ export class TestCaseRecorder {
117118
: null;
118119

119120
this.toggle = this.toggle.bind(this);
121+
this.recordOneThenPause = this.recordOneThenPause.bind(this);
120122
this.pause = this.pause.bind(this);
121123
this.resume = this.resume.bind(this);
122124
this.takeSnapshot = this.takeSnapshot.bind(this);
@@ -130,6 +132,15 @@ export class TestCaseRecorder {
130132
return await this.start(arg);
131133
}
132134
}
135+
136+
async recordOneThenPause(arg?: RecordTestCaseCommandArg) {
137+
this.pauseAfterNextCommand = true;
138+
this.paused = false;
139+
if (!this.active) {
140+
return await this.start(arg);
141+
}
142+
}
143+
133144
async pause() {
134145
if (!this.active) {
135146
throw Error("Asked to pause recording, but no recording active");
@@ -290,6 +301,7 @@ export class TestCaseRecorder {
290301
stop() {
291302
this.active = false;
292303
this.paused = false;
304+
this.pauseAfterNextCommand = false;
293305
}
294306

295307
async preCommandHook(hatTokenMap: ReadOnlyHatMap, command: CommandLatest) {
@@ -400,6 +412,10 @@ export class TestCaseRecorder {
400412
}
401413

402414
this.testCase = null;
415+
if (this.pauseAfterNextCommand) {
416+
this.paused = true;
417+
this.pauseAfterNextCommand = false;
418+
}
403419
}
404420

405421
private async writeToFile(outPath: string, fixture: string) {

packages/cursorless-vscode/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"onCommand:cursorless.pauseRecording",
6161
"onCommand:cursorless.recomputeDecorationStyles",
6262
"onCommand:cursorless.recordTestCase",
63+
"onCommand:cursorless.recordOneTestCaseThenPause",
6364
"onCommand:cursorless.resumeRecording",
6465
"onCommand:cursorless.showCheatsheet",
6566
"onCommand:cursorless.showDocumentation",
@@ -89,6 +90,10 @@
8990
"command": "cursorless.recordTestCase",
9091
"title": "Cursorless: Record test case"
9192
},
93+
{
94+
"command": "cursorless.recordOneTestCaseThenPause",
95+
"title": "Cursorless: Record one test case, then pause"
96+
},
9297
{
9398
"command": "cursorless.pauseRecording",
9499
"title": "Cursorless: Pause test case recording"

packages/cursorless-vscode/src/registerCommands.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export function registerCommands(
4646

4747
// Testcase recorder commands
4848
["cursorless.recordTestCase"]: testCaseRecorder.toggle,
49+
["cursorless.recordOneTestCaseThenPause"]:
50+
testCaseRecorder.recordOneThenPause,
4951
["cursorless.pauseRecording"]: testCaseRecorder.pause,
5052
["cursorless.resumeRecording"]: testCaseRecorder.resume,
5153
["cursorless.takeSnapshot"]: testCaseRecorder.takeSnapshot,

0 commit comments

Comments
 (0)