Skip to content

Commit 94d648c

Browse files
Handle tab input being undefined (#2468)
## 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 abfafa1 commit 94d648c

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

packages/cursorless-vscode/src/ide/vscode/VscodeFocusEditor.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { getCellIndex } from "@cursorless/vscode-common";
22
import {
33
commands,
44
NotebookDocument,
5+
TabInputTextDiff,
56
TextEditor,
67
ViewColumn,
78
window,
@@ -58,12 +59,15 @@ function getViewColumn(editor: TextEditor): ViewColumn | undefined {
5859
}
5960
const uri = editor.document.uri.toString();
6061
const tabGroup = window.tabGroups.all.find((tabGroup) =>
61-
tabGroup.tabs.find(
62-
(tab: any) =>
63-
tab.input.uri?.toString() === uri ||
64-
tab.input.original?.toString() === uri ||
65-
tab.input.modified?.toString() === uri,
66-
),
62+
tabGroup.tabs.find((tab) => {
63+
if (tab.input instanceof TabInputTextDiff) {
64+
return (
65+
tab.input.original.toString() === uri ||
66+
tab.input.modified.toString() === uri
67+
);
68+
}
69+
return (tab as any).input?.uri?.toString() === uri;
70+
}),
6771
);
6872
return tabGroup?.viewColumn;
6973
}

packages/cursorless-vscode/src/ide/vscode/isDiffEditorOriginal.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TextEditor, window } from "vscode";
1+
import { TabInputTextDiff, TextEditor, window } from "vscode";
22

33
/**
44
* @param editor The editor to check
@@ -10,6 +10,10 @@ export function isDiffEditorOriginal(editor: TextEditor): boolean {
1010
}
1111
const uri = editor.document.uri.toString();
1212
return window.tabGroups.all.some((tabGroup) =>
13-
tabGroup.tabs.find((tab: any) => tab.input.original?.toString() === uri),
13+
tabGroup.tabs.find(
14+
(tab) =>
15+
tab.input instanceof TabInputTextDiff &&
16+
tab.input.original.toString() === uri,
17+
),
1418
);
1519
}

0 commit comments

Comments
 (0)