Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fire source control hooks for opened and closed documents #1414

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {

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

/** The stringified URIs of all `isfs` documents that are currently open in a UI tab */
const isfsTabs: string[] = [];

// Create this here so we can fire its event
const fileDecorationProvider = new FileDecorationProvider();

Expand Down Expand Up @@ -1140,6 +1143,11 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
if (idx > -1) {
openedClasses.splice(idx, 1);
}
const isfsIdx = isfsTabs.indexOf(uri);
if (isfsIdx > -1) {
isfsTabs.splice(isfsIdx, 1);
fireOtherStudioAction(OtherStudioAction.ClosedDocument, doc.uri);
}
}),
vscode.commands.registerCommand("vscode-objectscript.addItemsToProject", (item) => {
return modifyProject(item instanceof NodeBase || item instanceof vscode.Uri ? item : undefined, "add");
Expand Down Expand Up @@ -1431,6 +1439,22 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
DocumentContentProvider.getUri(doc, undefined, undefined, undefined, wsFolder.uri)
);
}),
vscode.window.tabGroups.onDidChangeTabs((e) => {
const processUri = (uri: vscode.Uri): void => {
if (uri.scheme == FILESYSTEM_SCHEMA) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the events not wanted for documents coming from isfs-readonly folders?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. For example, we only show the source control menu for isfs files. What do you think @isc-tleavitt?

isfsTabs.push(uri.toString());
fireOtherStudioAction(OtherStudioAction.OpenedDocument, uri);
}
};
for (const t of e.opened) {
if (t.input instanceof vscode.TabInputText || t.input instanceof vscode.TabInputCustom) {
processUri(t.input.uri);
} else if (t.input instanceof vscode.TabInputTextDiff) {
processUri(t.input.original);
processUri(t.input.modified);
}
}
}),
...setUpTestController(),

/* Anything we use from the VS Code proposed API */
Expand Down