Skip to content

Commit 91e50ac

Browse files
committed
Add serverName, active and apiVersion to object returned by serverForUri API
1 parent 438bb09 commit 91e50ac

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

src/api/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const DEFAULT_API_VERSION = 1;
2020
import * as Atelier from "./atelier";
2121

2222
export interface ConnectionSettings {
23+
serverName: string;
2324
active: boolean;
2425
apiVersion: number;
2526
https: boolean;
@@ -47,7 +48,7 @@ export class AtelierAPI {
4748
}
4849

4950
public get config(): ConnectionSettings {
50-
const { active = false, https = false, pathPrefix = "", username } = this._config;
51+
const { serverName, active = false, https = false, pathPrefix = "", username } = this._config;
5152
const ns = this.namespace || this._config.ns;
5253
const host = this.externalServer
5354
? this._config.host
@@ -58,6 +59,7 @@ export class AtelierAPI {
5859
const password = workspaceState.get(this.configName + ":password", this._config.password);
5960
const apiVersion = workspaceState.get(this.configName + ":apiVersion", DEFAULT_API_VERSION);
6061
return {
62+
serverName,
6163
active,
6264
apiVersion,
6365
https,
@@ -164,13 +166,14 @@ export class AtelierAPI {
164166
serverName = "";
165167
}
166168

167-
if (serverName && serverName.length) {
169+
if (serverName !== "") {
168170
const {
169171
webServer: { scheme, host, port, pathPrefix = "" },
170172
username,
171173
password,
172174
} = getResolvedConnectionSpec(serverName, config("intersystems.servers", workspaceFolderName).get(serverName));
173175
this._config = {
176+
serverName,
174177
active: this.externalServer || conn.active,
175178
apiVersion: workspaceState.get(this.configName + ":apiVersion", DEFAULT_API_VERSION),
176179
https: scheme === "https",
@@ -190,6 +193,7 @@ export class AtelierAPI {
190193
}
191194
} else {
192195
this._config = conn;
196+
this._config.serverName = serverName;
193197
}
194198
}
195199

src/extension.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,30 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
697697
serverForUri(uri: vscode.Uri): any {
698698
const { apiTarget } = connectionTarget(uri);
699699
const api = new AtelierAPI(apiTarget);
700-
const { host = "", https, port = 0, pathPrefix, username, password, ns = "" } = api.config;
701-
return { scheme: https ? "https" : "http", host, port, pathPrefix, username, password, namespace: ns };
700+
const {
701+
serverName,
702+
active,
703+
host = "",
704+
https,
705+
port,
706+
pathPrefix,
707+
username,
708+
password,
709+
ns = "",
710+
apiVersion,
711+
} = api.config;
712+
return {
713+
serverName,
714+
active,
715+
scheme: https ? "https" : "http",
716+
host,
717+
port,
718+
pathPrefix,
719+
username,
720+
password,
721+
namespace: ns,
722+
apiVersion: active ? apiVersion : undefined,
723+
};
702724
},
703725
};
704726

0 commit comments

Comments
 (0)