Skip to content

Commit ef66f3a

Browse files
authored
Fire source control hooks for opened and closed documents (#1414)
1 parent 065df42 commit ef66f3a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/extension.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
820820

821821
openedClasses = workspaceState.get("openedClasses") ?? [];
822822

823+
/** The stringified URIs of all `isfs` documents that are currently open in a UI tab */
824+
const isfsTabs: string[] = [];
825+
823826
// Create this here so we can fire its event
824827
const fileDecorationProvider = new FileDecorationProvider();
825828

@@ -1180,6 +1183,11 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
11801183
if (idx > -1) {
11811184
openedClasses.splice(idx, 1);
11821185
}
1186+
const isfsIdx = isfsTabs.indexOf(uri);
1187+
if (isfsIdx > -1) {
1188+
isfsTabs.splice(isfsIdx, 1);
1189+
fireOtherStudioAction(OtherStudioAction.ClosedDocument, doc.uri);
1190+
}
11831191
}),
11841192
vscode.commands.registerCommand("vscode-objectscript.addItemsToProject", (item) => {
11851193
return modifyProject(item instanceof NodeBase || item instanceof vscode.Uri ? item : undefined, "add");
@@ -1476,6 +1484,22 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
14761484
DocumentContentProvider.getUri(doc, undefined, undefined, undefined, wsFolder.uri)
14771485
);
14781486
}),
1487+
vscode.window.tabGroups.onDidChangeTabs((e) => {
1488+
const processUri = (uri: vscode.Uri): void => {
1489+
if (uri.scheme == FILESYSTEM_SCHEMA) {
1490+
isfsTabs.push(uri.toString());
1491+
fireOtherStudioAction(OtherStudioAction.OpenedDocument, uri);
1492+
}
1493+
};
1494+
for (const t of e.opened) {
1495+
if (t.input instanceof vscode.TabInputText || t.input instanceof vscode.TabInputCustom) {
1496+
processUri(t.input.uri);
1497+
} else if (t.input instanceof vscode.TabInputTextDiff) {
1498+
processUri(t.input.original);
1499+
processUri(t.input.modified);
1500+
}
1501+
}
1502+
}),
14791503
...setUpTestController(),
14801504

14811505
/* Anything we use from the VS Code proposed API */

0 commit comments

Comments
 (0)