Skip to content

Commit fba481f

Browse files
committed
Fire source control hooks for opened and closed documents
1 parent 5255bac commit fba481f

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

@@ -1140,6 +1143,11 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
11401143
if (idx > -1) {
11411144
openedClasses.splice(idx, 1);
11421145
}
1146+
const isfsIdx = isfsTabs.indexOf(uri);
1147+
if (isfsIdx > -1) {
1148+
isfsTabs.splice(isfsIdx, 1);
1149+
fireOtherStudioAction(OtherStudioAction.ClosedDocument, doc.uri);
1150+
}
11431151
}),
11441152
vscode.commands.registerCommand("vscode-objectscript.addItemsToProject", (item) => {
11451153
return modifyProject(item instanceof NodeBase || item instanceof vscode.Uri ? item : undefined, "add");
@@ -1431,6 +1439,22 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
14311439
DocumentContentProvider.getUri(doc, undefined, undefined, undefined, wsFolder.uri)
14321440
);
14331441
}),
1442+
vscode.window.tabGroups.onDidChangeTabs((e) => {
1443+
const processUri = (uri: vscode.Uri): void => {
1444+
if (uri.scheme == FILESYSTEM_SCHEMA) {
1445+
isfsTabs.push(uri.toString());
1446+
fireOtherStudioAction(OtherStudioAction.OpenedDocument, uri);
1447+
}
1448+
};
1449+
for (const t of e.opened) {
1450+
if (t.input instanceof vscode.TabInputText || t.input instanceof vscode.TabInputCustom) {
1451+
processUri(t.input.uri);
1452+
} else if (t.input instanceof vscode.TabInputTextDiff) {
1453+
processUri(t.input.original);
1454+
processUri(t.input.modified);
1455+
}
1456+
}
1457+
}),
14341458
...setUpTestController(),
14351459

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

0 commit comments

Comments
 (0)