Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
"editor.tabSize": 2,
"editor.formatOnSave": true
},
"js/ts.tsdk.path": "node_modules/typescript/lib",
}
10 changes: 2 additions & 8 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
checkConnection,
schemas,
checkingConnection,
inactiveServerIds,
} from "../extension";
import { currentWorkspaceFolder, outputChannel, outputConsole } from "../utils";

Expand Down Expand Up @@ -232,7 +233,7 @@ export class AtelierAPI {
} = getResolvedConnectionSpec(serverName, config("intersystems.servers", workspaceFolderName).get(serverName));
this._config = {
serverName,
active: this.externalServer || conn.active,
active: !inactiveServerIds.has(serverName),
apiVersion: workspaceState.get(this.configName.toLowerCase() + ":apiVersion", DEFAULT_API_VERSION),
serverVersion: workspaceState.get(this.configName.toLowerCase() + ":serverVersion", DEFAULT_SERVER_VERSION),
https: scheme === "https",
Expand All @@ -245,13 +246,6 @@ export class AtelierAPI {
pathPrefix,
docker: false,
};

// Report server as inactive when no namespace has been determined,
// otherwise output channel reports the issue.
// This arises when a server-only workspace is editing the user's settings.json, or the .code-workspace file.
if (this._config.ns === "" && this.externalServer) {
this._config.active = false;
}
} else if (conn["docker-compose"]) {
// Provided a docker-compose type connection spec has previously been resolved we can use its values
const resolvedSpec = getResolvedConnectionSpec(workspaceFolderName, undefined);
Expand Down
24 changes: 14 additions & 10 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ export function getResolvedConnectionSpec(key: string, dflt: any): any {
return dflt;
}

/** The `api.serverId`s of all servers that are known to be inactive */
export const inactiveServerIds: Set<string> = new Set();

export async function checkConnection(
clearCookies = false,
uri?: vscode.Uri,
Expand Down Expand Up @@ -432,9 +435,8 @@ export async function checkConnection(
handleError(message);
panel.text = `${PANEL_LABEL} $(error)`;
panel.tooltip = `ERROR - ${message}`;
if (!api.externalServer) {
await setConnectionState(configName, false);
}
inactiveServerIds.add(api.serverId);
if (!api.externalServer) await setConnectionState(configName, false);
return;
}
checkingConnection = true;
Expand All @@ -448,9 +450,8 @@ export async function checkConnection(
} else {
panel.tooltip = new vscode.MarkdownString(`Connected as \`${username}\``);
}
if (!api.externalServer) {
await setConnectionState(configName, true);
}
inactiveServerIds.delete(api.serverId);
if (!api.externalServer) await setConnectionState(configName, true);
return;
};

Expand Down Expand Up @@ -503,7 +504,8 @@ export async function checkConnection(
});
}
} else {
await setConnectionState(configName, false);
inactiveServerIds.add(api.serverId);
if (!api.externalServer) await setConnectionState(configName, false);
}
} else {
success = await new Promise<boolean>((resolve) => {
Expand Down Expand Up @@ -535,8 +537,9 @@ export async function checkConnection(
checkingConnection = false;
})
);
} else if (!api.externalServer) {
await setConnectionState(configName, false);
} else {
inactiveServerIds.add(api.serverId);
if (!api.externalServer) await setConnectionState(configName, false);
}
resolve(false);
});
Expand All @@ -554,7 +557,8 @@ export async function checkConnection(
);
panel.text = `${connInfo} $(error)`;
panel.tooltip = `ERROR - ${message}`;
await setConnectionState(configName, false);
inactiveServerIds.add(api.serverId);
if (!api.externalServer) await setConnectionState(configName, false);
})
.finally(() => {
checkingConnection = false;
Expand Down
Loading