Skip to content

Commit 3a46c0e

Browse files
committed
Always use connection string as key to avoid using ouytdated values if config changes
1 parent 66a5fa8 commit 3a46c0e

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/explorer/nodes.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,8 @@ export class RootNode extends NodeBase {
183183
api.setNamespace(this.namespace);
184184
if (category == "CSP" && path == "") {
185185
// Use the results from the getCSPApps() API
186-
const cspAppsKey = (
187-
api.config.serverName && api.config.serverName != ""
188-
? `${api.config.serverName}:${api.config.ns}`
189-
: `${api.config.host}:${api.config.port}${api.config.pathPrefix}:${api.config.ns}`
190-
).toLowerCase();
186+
const cspAppsKey =
187+
`${api.config.host}:${api.config.port}${api.config.pathPrefix}:[${api.config.ns}]`.toLowerCase();
191188
let nsCspApps: string[] | undefined = cspApps.get(cspAppsKey);
192189
if (nsCspApps == undefined) {
193190
nsCspApps = await api.getCSPApps().then((data) => data.result.content || []);

src/extension.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,8 @@ async function updateWebAndAbstractDocsCaches(wsFolders: readonly vscode.Workspa
761761
for (const wsFolder of wsFolders) {
762762
const api = new AtelierAPI(wsFolder.uri);
763763
if (!api.active) continue;
764-
const key = `${api.serverId}:${api.config.ns}`.toLowerCase();
764+
const { host, port, pathPrefix, ns } = api.config;
765+
const key = `${host}:${port}${pathPrefix}[${ns}]`.toLowerCase();
765766
if (keys.has(key)) continue;
766767
keys.add(key);
767768
connections.push({ key, api });

src/utils/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ export const outputChannel = vscode.window.createOutputChannel("ObjectScript", o
2323

2424
/**
2525
* A map of all CSP web apps in a server-namespace.
26-
* The key is either `serverName:ns`, or `host:port/pathPrefix:ns`, lowercase.
26+
* The key is `host:port/pathPrefix[ns]`, lowercase.
2727
* The value is an array of CSP apps as returned by GET %25SYS/cspapps.
2828
*/
2929
export const cspApps: Map<string, string[]> = new Map();
3030

3131
/**
3232
* A map of all Studio Abstract Document extensions in a server-namespace.
33-
* The key is either `serverName:ns`, or `host:port/pathPrefix:ns`, lowercase.
33+
* The key is `host:port/pathPrefix[ns]`, lowercase.
3434
* The value is lowercase array of file extensions, without the dot.
3535
*/
3636
export const otherDocExts: Map<string, string[]> = new Map();
@@ -146,15 +146,17 @@ export function cspAppsForUri(uri: vscode.Uri): string[] {
146146

147147
/** Get a list of all CSP web apps in the server-namespace that `api` is connected to. */
148148
export function cspAppsForApi(api: AtelierAPI): string[] {
149-
return cspApps.get(`${api.serverId}:${api.config.ns}`.toLowerCase()) ?? [];
149+
const { host, port, pathPrefix, ns } = api.config;
150+
return cspApps.get(`${host}:${port}${pathPrefix}[${ns}]`.toLowerCase()) ?? [];
150151
}
151152

152153
/**
153154
* Get a list of Studio Abstract Document extensions in the server-namespace that `uri` is connected to.
154155
*/
155156
function otherDocExtsForUri(uri: vscode.Uri): string[] {
156157
const api = new AtelierAPI(uri);
157-
return otherDocExts.get(`${api.serverId}:${api.config.ns}`.toLowerCase()) ?? [];
158+
const { host, port, pathPrefix, ns } = api.config;
159+
return otherDocExts.get(`${host}:${port}${pathPrefix}[${ns}]`.toLowerCase()) ?? [];
158160
}
159161

160162
/** Determine the server name of a non-`isfs` non-ObjectScript file (any file that's not CLS,MAC,INT,INC). */
@@ -642,7 +644,8 @@ export async function addWsServerRootFolderData(wsFolders: readonly vscode.Works
642644
if (value.redirectDotvscode) {
643645
// We must redirect .vscode Uris for this folder, so see
644646
// if the web app to do so is configured on the server
645-
const key = `${api.serverId}:%SYS`.toLowerCase();
647+
const { host, port, pathPrefix, ns } = api.config;
648+
const key = `${host}:${port}${pathPrefix}[${ns}]`.toLowerCase();
646649
let webApps = cspApps.get(key);
647650
if (!webApps) {
648651
webApps = await api

0 commit comments

Comments
 (0)