Skip to content

Commit c2e5a8d

Browse files
committed
Fix keyboard broken by #2235
This was not caught by our tests because we mock away command server. Not sure how to prevent this sort of thing in the future
1 parent a1bb6e4 commit c2e5a8d

File tree

6 files changed

+9
-15
lines changed

6 files changed

+9
-15
lines changed

packages/common/src/FakeCommandServerApi.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export class FakeCommandServerApi implements CommandServerApi {
1010

1111
constructor() {
1212
this.signals = { prePhrase: { getVersion: async () => null } };
13-
this.focusedElementType = "textEditor";
1413
}
1514

1615
async getFocusedElementType(): Promise<FocusedElementType | undefined> {

packages/common/src/types/CommandServerApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface CommandServerApi {
99
};
1010
}
1111

12-
export type FocusedElementType = "textEditor" | "terminal";
12+
export type FocusedElementType = "textEditor" | "terminal" | "other";
1313

1414
export interface InboundSignal {
1515
getVersion(): Promise<string | null>;

packages/common/src/types/TestCaseFixture.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface TestCaseFixtureBase {
1515
/**
1616
* The type of element that is focused before the command is executed. If undefined default to text editor.
1717
*/
18-
focusedElementType?: FocusedElementType | "other";
18+
focusedElementType?: FocusedElementType;
1919

2020
/**
2121
* A list of marks to check in the case of navigation map test otherwise undefined

packages/cursorless-engine/src/core/getCommandFallback.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ export async function getCommandFallback(
1414
runAction: (actionDescriptor: ActionDescriptor) => Promise<ActionReturnValue>,
1515
command: CommandComplete,
1616
): Promise<Fallback | null> {
17-
if (
18-
commandServerApi == null ||
19-
(await commandServerApi.getFocusedElementType()) === "textEditor"
20-
) {
17+
const focusedElementType = await commandServerApi?.getFocusedElementType();
18+
19+
if (focusedElementType == null || focusedElementType === "textEditor") {
2120
return null;
2221
}
2322

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ export class TestCase {
141141
const fixture: EnforceUndefined<TestCaseFixture> = {
142142
languageId: this.languageId,
143143
focusedElementType:
144-
this.focusedElementType !== "textEditor"
145-
? this.focusedElementType ?? "other"
146-
: undefined,
144+
this.focusedElementType === "textEditor"
145+
? undefined
146+
: this.focusedElementType,
147147
postEditorOpenSleepTimeMs: undefined,
148148
postCommandSleepTimeMs: undefined,
149149
command: this.command,

packages/cursorless-vscode-e2e/src/suite/recorded.vscode.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,7 @@ async function runTest(file: string, spyIde: SpyIDE) {
104104
// spyIde.clipboard.writeText(fixture.initialState.clipboard);
105105
}
106106

107-
commandServerApi.setFocusedElementType(
108-
fixture.focusedElementType === "other"
109-
? undefined
110-
: fixture.focusedElementType ?? "textEditor",
111-
);
107+
commandServerApi.setFocusedElementType(fixture.focusedElementType);
112108

113109
// Ensure that the expected hats are present
114110
await hatTokenMap.allocateHats(

0 commit comments

Comments
 (0)