Skip to content

Fix breakage v3.0 caused to the InterSystems Testing Manager extension #1619

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

Closed
Closed
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
38 changes: 26 additions & 12 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,25 +605,39 @@ export async function addWsServerRootFolderData(wsFolders: readonly vscode.Works
if (!wsFolders?.length) return;
return Promise.allSettled(
wsFolders.map(async (wsFolder) => {
if (notIsfs(wsFolder.uri)) return;
const api = new AtelierAPI(wsFolder.uri);
if (!api.active) return;
const value: WSServerRootFolderData = {
redirectDotvscode: true,
canRedirectDotvscode: true,
};
if (isCSP(wsFolder.uri) && !["", "/"].includes(wsFolder.uri.path)) {
// A CSP-type root folder for a specific webapp that already has a
// .vscode/settings.json file must not redirect .vscode/* references
await api
.headDoc(`${wsFolder.uri.path}${!wsFolder.uri.path.endsWith("/") ? "/" : ""}.vscode/settings.json`)
.then(() => {
value.redirectDotvscode = false;
})
.catch(() => {});
let folderKey: string;
if (wsFolder.uri.scheme === "file") {
// Special case where folder is local and has an active server connection.
// Allow extensions such as InterSystems Testing Manager (intersystems-community.testingmanager)
// to access the corresponding server-side .vscode subtree using an ISFS uri.
folderKey = vscode.Uri.from({
scheme: "isfs",
authority: wsFolder.name,
path: "/",
query: `ns=${api.ns}`,
}).toString();
} else {
if (notIsfs(wsFolder.uri)) return;
folderKey = wsFolder.uri.toString();
if (isCSP(wsFolder.uri) && !["", "/"].includes(wsFolder.uri.path)) {
// A CSP-type isfs root folder for a specific webapp that already has a
// .vscode/settings.json file must not redirect .vscode/* references
await api
.headDoc(`${wsFolder.uri.path}${!wsFolder.uri.path.endsWith("/") ? "/" : ""}.vscode/settings.json`)
.then(() => {
value.redirectDotvscode = false;
})
.catch(() => {});
}
}
if (value.redirectDotvscode) {
// We must redirect .vscode Uris for this folder, so see
// We must redirect .vscode isfs Uris for this folder, so see
// if the web app to do so is configured on the server
const key = `${api.serverId}:%SYS`.toLowerCase();
let webApps = cspApps.get(key);
Expand All @@ -636,7 +650,7 @@ export async function addWsServerRootFolderData(wsFolders: readonly vscode.Works
}
value.canRedirectDotvscode = webApps.includes("/_vscode");
}
wsServerRootFolders.set(wsFolder.uri.toString(), value);
wsServerRootFolders.set(folderKey, value);
})
);
}
Expand Down