diff --git a/src/TestCaseRecorder.ts b/src/TestCaseRecorder.ts index 510695d1ed..d4ce940e65 100644 --- a/src/TestCaseRecorder.ts +++ b/src/TestCaseRecorder.ts @@ -6,8 +6,6 @@ import { walkDirsSync } from "./test/suite/walkSync"; export class TestCaseRecorder { active: boolean = false; - outPath: string | null = null; - spokenForm: string | null = null; workspacePath: string | null; workSpaceFolder: string | null; fixtureRoot: string | null; @@ -28,23 +26,19 @@ export class TestCaseRecorder { : null; } - start(): Promise { - this.active = true; - return this.promptSpokenForm(); + async start(): Promise { + this.active = await this.promptSubdirectory(); + return this.active; } - async finish(testCase: TestCase): Promise { + stop() { this.active = false; - const outPath = await this.promptSubdirectory(); - const fixture = testCase.toYaml(); - - if (outPath) { - this.writeToFile(outPath, fixture); - } else { - this.showFixture(fixture); - } + } - return outPath; + async finish(testCase: TestCase): Promise { + const outPath = this.calculateFilePath(testCase); + const fixture = testCase.toYaml(); + await this.writeToFile(outPath, fixture); } private async writeToFile(outPath: string, fixture: string) { @@ -59,39 +53,13 @@ export class TestCaseRecorder { }); } - private async showFixture(fixture: string) { - const document = await vscode.workspace.openTextDocument({ - language: "yaml", - content: fixture, - }); - await vscode.window.showTextDocument(document, { - viewColumn: vscode.ViewColumn.Beside, - }); - } - - private async promptSpokenForm(): Promise { - const result = await vscode.window.showInputBox({ - prompt: "Talon Command", - ignoreFocusOut: true, - validateInput: (input) => (input.trim().length > 0 ? null : "Required"), - }); - - // Inputs return undefined when a user cancels by hitting 'escape' - if (result === undefined) { - this.active = false; - return; - } - - this.spokenForm = result; - } - - private async promptSubdirectory(): Promise { + private async promptSubdirectory(): Promise { if ( this.workspacePath == null || this.fixtureRoot == null || this.workSpaceFolder !== "cursorless-vscode" ) { - return null; + throw new Error("Can't prompt for subdirectory"); } const subdirectories = walkDirsSync(this.fixtureRoot).concat("/"); @@ -103,16 +71,16 @@ export class TestCaseRecorder { ]); if (subdirectorySelection === undefined) { - return null; + return false; } else if (subdirectorySelection === createNewSubdirectory) { return this.promptNewSubdirectory(); } else { this.fixtureSubdirectory = subdirectorySelection; - return this.promptFileName(); + return true; } } - private async promptNewSubdirectory(): Promise { + private async promptNewSubdirectory(): Promise { if (this.fixtureRoot == null) { throw new Error("Missing fixture root. Not in cursorless workspace?"); } @@ -128,32 +96,43 @@ export class TestCaseRecorder { } this.fixtureSubdirectory = subdirectory; - return this.promptFileName(); + return true; } - private async promptFileName(): Promise { + private calculateFilePath(testCase: TestCase): string { if (this.fixtureRoot == null) { throw new Error("Missing fixture root. Not in cursorless workspace?"); } - const filename = await vscode.window.showInputBox({ - prompt: "Fixture Filename", - }); - - if (filename === undefined || this.fixtureSubdirectory == null) { - return this.promptSubdirectory(); // go back a prompt - } - const targetDirectory = path.join( this.fixtureRoot, - this.fixtureSubdirectory + this.fixtureSubdirectory! ); if (!fs.existsSync(targetDirectory)) { fs.mkdirSync(targetDirectory); } - this.outPath = path.join(targetDirectory, `${filename}.yml`); - return this.outPath; + let filename = camelize(testCase.spokenForm); + let filePath = path.join(targetDirectory, `${filename}.yml`); + + let i = 2; + while (fs.existsSync(filePath)) { + filename += i++; + filePath = path.join(targetDirectory, `${filename}.yml`); + } + + return filePath; } } + +function camelize(str: string) { + return str + .split(" ") + .map((str, index) => (index === 0 ? str : capitalize(str))) + .join(""); +} + +function capitalize(str: string) { + return str.charAt(0).toUpperCase() + str.slice(1); +} diff --git a/src/extension.ts b/src/extension.ts index d4e9d52cf3..b83a4e02f3 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -79,21 +79,33 @@ export async function activate(context: vscode.ExtensionContext) { const graph = makeGraph(graphConstructors); const thatMark = new ThatMark(); const testCaseRecorder = new TestCaseRecorder(context); + const cursorlessRecordTestCaseDisposable = vscode.commands.registerCommand( "cursorless.recordTestCase", async () => { - console.log("Recording test case for next command"); - testCaseRecorder.start(); + if (testCaseRecorder.active) { + vscode.window.showInformationMessage("Stopped recording test cases"); + testCaseRecorder.stop(); + } else { + if (await testCaseRecorder.start()) { + vscode.window.showInformationMessage( + "Recording test cases for following commands" + ); + } + } } ); + const cursorlessCommandDisposable = vscode.commands.registerCommand( "cursorless.command", async ( + spokenForm: string, actionName: ActionType, partialTargets: PartialTarget[], ...extraArgs: any[] ) => { try { + console.debug(`spokenForm: ${spokenForm}`); console.debug(`action: ${actionName}`); console.debug(`partialTargets:`); console.debug(JSON.stringify(partialTargets, null, 3)); @@ -109,14 +121,9 @@ export async function activate(context: vscode.ExtensionContext) { const isPaste = actionName === "paste"; - var clipboardContents: string | undefined; - - if (isPaste) { - clipboardContents = await Clipboard.readText(); - // clipboardContents = "hello"; - // clipboardContents = "hello\n"; - // clipboardContents = "\nhello\n"; - } + const clipboardContents = isPaste + ? await Clipboard.readText() + : undefined; const inferenceContext = { selectionContents, @@ -151,7 +158,7 @@ export async function activate(context: vscode.ExtensionContext) { targets, thatMark: thatMark, navigationMap: graph.navigationMap!, - spokenForm: testCaseRecorder.spokenForm ?? "", + spokenForm, }; testCase = new TestCase(command, context); await testCase.recordInitialState(); diff --git a/src/test/suite/fixtures/recorded/actions/bringMade.yml b/src/test/suite/fixtures/recorded/actions/bringMade.yml new file mode 100644 index 0000000000..159dbca869 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/bringMade.yml @@ -0,0 +1,33 @@ +spokenForm: bring made +languageId: typescript +command: + actionName: bring + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: m} + - type: primitive + mark: {type: cursor} + selectionType: token + position: contents + modifier: {type: identity} + insideOutsideType: inside + extraArgs: [] +marks: + default.m: + start: {line: 0, character: 6} + end: {line: 0, character: 21} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "const myVariableValue = \"hello\";\r\nmyVariableValue" + selections: + - anchor: {line: 1, character: 15} + active: {line: 1, character: 15} + thatMark: + - anchor: {line: 1, character: 15} + active: {line: 1, character: 0} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: null}, {type: primitive, mark: {type: cursor}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/bringMadeToCap.yml b/src/test/suite/fixtures/recorded/actions/bringMadeToCap.yml new file mode 100644 index 0000000000..97c70c0577 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/bringMadeToCap.yml @@ -0,0 +1,32 @@ +spokenForm: bring made to cap +languageId: typescript +command: + actionName: bring + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: m} + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + extraArgs: [] +marks: + default.m: + start: {line: 0, character: 6} + end: {line: 0, character: 21} + default.c: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "myVariableValue myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} + thatMark: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 15} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: null}, {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: null}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/carveMade.yml b/src/test/suite/fixtures/recorded/actions/carveMade.yml new file mode 100644 index 0000000000..c8bf24127c --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/carveMade.yml @@ -0,0 +1,27 @@ +spokenForm: carve made +languageId: typescript +command: + actionName: cut + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: m} + extraArgs: [] +marks: + default.m: + start: {line: 0, character: 6} + end: {line: 0, character: 21} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "const = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} + thatMark: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: null}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/chuckMade.yml b/src/test/suite/fixtures/recorded/actions/chuckMade.yml new file mode 100644 index 0000000000..59dd2efdad --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/chuckMade.yml @@ -0,0 +1,27 @@ +spokenForm: chuck made +languageId: typescript +command: + actionName: delete + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: m} + extraArgs: [] +marks: + default.m: + start: {line: 0, character: 6} + end: {line: 0, character: 21} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "const = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} + thatMark: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: outside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/clearMade.yml b/src/test/suite/fixtures/recorded/actions/clearMade.yml new file mode 100644 index 0000000000..dbf7463e30 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/clearMade.yml @@ -0,0 +1,27 @@ +spokenForm: clear made +languageId: typescript +command: + actionName: clear + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: m} + extraArgs: [] +marks: + default.m: + start: {line: 0, character: 6} + end: {line: 0, character: 21} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "const = \"hello\";\r\n" + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} + thatMark: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/commentCap.yml b/src/test/suite/fixtures/recorded/actions/commentCap.yml new file mode 100644 index 0000000000..24d442699b --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/commentCap.yml @@ -0,0 +1,27 @@ +spokenForm: comment cap +languageId: typescript +command: + actionName: commentLines + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + extraArgs: [] +marks: + default.c: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "// const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} + thatMark: + - anchor: {line: 0, character: 3} + active: {line: 0, character: 8} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/dedentCap.yml b/src/test/suite/fixtures/recorded/actions/dedentCap.yml new file mode 100644 index 0000000000..ae6d97e979 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/dedentCap.yml @@ -0,0 +1,27 @@ +spokenForm: dedent cap +languageId: typescript +command: + actionName: outdentLines + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + extraArgs: [] +marks: + default.c: + start: {line: 0, character: 4} + end: {line: 0, character: 9} +initialState: + documentContents: " const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} + thatMark: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/drinkCap.yml b/src/test/suite/fixtures/recorded/actions/drinkCap.yml new file mode 100644 index 0000000000..431ea475b9 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/drinkCap.yml @@ -0,0 +1,27 @@ +spokenForm: drink cap +languageId: typescript +command: + actionName: editNewLineAbove + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + extraArgs: [] +marks: + default.c: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "\r\nconst myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + thatMark: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: outside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/dropCap.yml b/src/test/suite/fixtures/recorded/actions/dropCap.yml new file mode 100644 index 0000000000..204c86f233 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/dropCap.yml @@ -0,0 +1,27 @@ +spokenForm: drop cap +languageId: typescript +command: + actionName: insertEmptyLineAbove + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + extraArgs: [] +marks: + default.c: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "\r\nconst myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 2, character: 0} + active: {line: 2, character: 0} + thatMark: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 5} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/dupeCap.yml b/src/test/suite/fixtures/recorded/actions/dupeCap.yml new file mode 100644 index 0000000000..df087fe971 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/dupeCap.yml @@ -0,0 +1,27 @@ +spokenForm: dupe cap +languageId: typescript +command: + actionName: copyLinesDown + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + extraArgs: [] +marks: + default.c: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} +finalState: + documentContents: "const myVariableValue = \"hello\";\r\nconst myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} + thatMark: + - anchor: {line: 0, character: 32} + active: {line: 1, character: 4} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/dupeUpCap.yml b/src/test/suite/fixtures/recorded/actions/dupeUpCap.yml new file mode 100644 index 0000000000..ebcb4cebab --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/dupeUpCap.yml @@ -0,0 +1,27 @@ +spokenForm: dupe up cap +languageId: typescript +command: + actionName: copyLinesUp + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + extraArgs: [] +marks: + default.c: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} +finalState: + documentContents: "const myVariableValue = \"hello\";\r\nconst myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + thatMark: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/findAllMade.yml b/src/test/suite/fixtures/recorded/actions/findAllMade.yml new file mode 100644 index 0000000000..eecd4c3b4c --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/findAllMade.yml @@ -0,0 +1,27 @@ +spokenForm: find all made +languageId: typescript +command: + actionName: findInFiles + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: m} + extraArgs: [] +marks: + default.m: + start: {line: 0, character: 6} + end: {line: 0, character: 21} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} + thatMark: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 21} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/floatCap.yml b/src/test/suite/fixtures/recorded/actions/floatCap.yml new file mode 100644 index 0000000000..920b373c21 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/floatCap.yml @@ -0,0 +1,27 @@ +spokenForm: float cap +languageId: typescript +command: + actionName: insertEmptyLineBelow + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + extraArgs: [] +marks: + default.c: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "const myVariableValue = \"hello\";\r\n\r\n" + selections: + - anchor: {line: 2, character: 0} + active: {line: 2, character: 0} + thatMark: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/moveMade.yml b/src/test/suite/fixtures/recorded/actions/moveMade.yml new file mode 100644 index 0000000000..0f924b75c5 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/moveMade.yml @@ -0,0 +1,33 @@ +spokenForm: move made +languageId: typescript +command: + actionName: move + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: m} + - type: primitive + mark: {type: cursor} + selectionType: token + position: contents + modifier: {type: identity} + insideOutsideType: inside + extraArgs: [] +marks: + default.m: + start: {line: 0, character: 6} + end: {line: 0, character: 21} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "const = \"hello\";\r\nmyVariableValue" + selections: + - anchor: {line: 1, character: 15} + active: {line: 1, character: 15} + thatMark: + - anchor: {line: 1, character: 15} + active: {line: 1, character: 0} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: null}, {type: primitive, mark: {type: cursor}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/moveMadeToCap.yml b/src/test/suite/fixtures/recorded/actions/moveMadeToCap.yml new file mode 100644 index 0000000000..85c9017902 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/moveMadeToCap.yml @@ -0,0 +1,32 @@ +spokenForm: move made to cap +languageId: typescript +command: + actionName: move + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: m} + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + extraArgs: [] +marks: + default.m: + start: {line: 0, character: 6} + end: {line: 0, character: 21} + default.c: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} + thatMark: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 15} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: null}, {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: null}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/pasteCap.yml b/src/test/suite/fixtures/recorded/actions/pasteCap.yml new file mode 100644 index 0000000000..63e6ed32f9 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/pasteCap.yml @@ -0,0 +1,29 @@ +spokenForm: paste cap +languageId: typescript +command: + actionName: paste + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + extraArgs: [] +marks: + default.c: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} + clipboard: myVariableValue +finalState: + documentContents: "myVariableValue myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} + clipboard: myVariableValue + thatMark: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 15} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/postMade.yml b/src/test/suite/fixtures/recorded/actions/postMade.yml new file mode 100644 index 0000000000..84d72e2ceb --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/postMade.yml @@ -0,0 +1,27 @@ +spokenForm: post made +languageId: typescript +command: + actionName: setSelectionAfter + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: m} + extraArgs: [] +marks: + default.m: + start: {line: 0, character: 6} + end: {line: 0, character: 21} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 0, character: 21} + active: {line: 0, character: 21} + thatMark: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 21} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/pourCap.yml b/src/test/suite/fixtures/recorded/actions/pourCap.yml new file mode 100644 index 0000000000..3f7db479e6 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/pourCap.yml @@ -0,0 +1,27 @@ +spokenForm: pour cap +languageId: typescript +command: + actionName: editNewLineBelow + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + extraArgs: [] +marks: + default.c: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "const myVariableValue = \"hello\";\r\n\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} + thatMark: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: outside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/preeMade.yml b/src/test/suite/fixtures/recorded/actions/preeMade.yml new file mode 100644 index 0000000000..498f559c72 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/preeMade.yml @@ -0,0 +1,27 @@ +spokenForm: pree made +languageId: typescript +command: + actionName: setSelectionBefore + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: m} + extraArgs: [] +marks: + default.m: + start: {line: 0, character: 6} + end: {line: 0, character: 21} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} + thatMark: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 21} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/puffCap.yml b/src/test/suite/fixtures/recorded/actions/puffCap.yml new file mode 100644 index 0000000000..98ccdc6748 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/puffCap.yml @@ -0,0 +1,27 @@ +spokenForm: puff cap +languageId: typescript +command: + actionName: insertEmptyLinesAround + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + extraArgs: [] +marks: + default.c: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "\r\nconst myVariableValue = \"hello\";\r\n\r\n" + selections: + - anchor: {line: 3, character: 0} + active: {line: 3, character: 0} + thatMark: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 5} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/swapCapWithMade.yml b/src/test/suite/fixtures/recorded/actions/swapCapWithMade.yml new file mode 100644 index 0000000000..66b826d5be --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/swapCapWithMade.yml @@ -0,0 +1,34 @@ +spokenForm: swap cap with made +languageId: typescript +command: + actionName: swap + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: m} + extraArgs: [] +marks: + default.c: + start: {line: 0, character: 0} + end: {line: 0, character: 5} + default.m: + start: {line: 0, character: 6} + end: {line: 0, character: 21} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "myVariableValue const = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} + thatMark: + - anchor: {line: 0, character: 16} + active: {line: 0, character: 21} + - anchor: {line: 0, character: 0} + active: {line: 0, character: 15} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: null}, {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: null}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/swapWithMade.yml b/src/test/suite/fixtures/recorded/actions/swapWithMade.yml new file mode 100644 index 0000000000..be5e533e88 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/swapWithMade.yml @@ -0,0 +1,30 @@ +spokenForm: swap with made +languageId: typescript +command: + actionName: swap + partialTargets: + - {type: primitive} + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: m} + extraArgs: [] +marks: + default.m: + start: {line: 0, character: 6} + end: {line: 0, character: 21} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 1, character: 0} + active: {line: 1, character: 0} +finalState: + documentContents: "const = \"hello\";\r\nmyVariableValue" + selections: + - anchor: {line: 1, character: 15} + active: {line: 1, character: 15} + thatMark: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} + - anchor: {line: 1, character: 15} + active: {line: 1, character: 0} +returnValue: null +fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: null}, {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: null}] \ No newline at end of file diff --git a/src/test/suite/fixtures/recorded/actions/takeMade.yml b/src/test/suite/fixtures/recorded/actions/takeMade.yml new file mode 100644 index 0000000000..101792acd0 --- /dev/null +++ b/src/test/suite/fixtures/recorded/actions/takeMade.yml @@ -0,0 +1,27 @@ +spokenForm: take made +languageId: typescript +command: + actionName: setSelection + partialTargets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: m} + extraArgs: [] +marks: + default.m: + start: {line: 0, character: 6} + end: {line: 0, character: 21} +initialState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 0, character: 30} + active: {line: 0, character: 30} +finalState: + documentContents: "const myVariableValue = \"hello\";\r\n" + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 21} + thatMark: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 21} +returnValue: null +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: m}, selectionType: token, position: contents, modifier: {type: identity}, insideOutsideType: inside}] \ No newline at end of file diff --git a/src/test/suite/recorded.test.ts b/src/test/suite/recorded.test.ts index 83b4cffd47..6c9a5ba2b1 100644 --- a/src/test/suite/recorded.test.ts +++ b/src/test/suite/recorded.test.ts @@ -96,6 +96,7 @@ suite("recorded test cases", async function () { const returnValue = await vscode.commands.executeCommand( "cursorless.command", + fixture.spokenForm, fixture.command.actionName, fixture.command.partialTargets, ...fixture.command.extraArgs