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
15 changes: 7 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"node-cmd": "^5.0.0"
},
"devDependencies": {
"@intersystems-community/intersystems-servermanager": "^3.8.0",
"@intersystems-community/intersystems-servermanager": "^3.10.2",
"@types/glob": "^7.1.1",
"@types/mocha": "^9.0.0",
"@types/node": "^20.14.0",
Expand Down
2 changes: 1 addition & 1 deletion src/api/getServerSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function getServerSummary(name: string, scope?: vscode.ConfigurationScope
if (!server) {
return undefined;
}
return { name, description: server.description || "", detail: serverDetail(server) };
return { name, description: server.description || "", detail: serverDetail(server), scope };
}

export function serverDetail(connSpec: IServerSpec): string {
Expand Down
17 changes: 15 additions & 2 deletions src/commonActivate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ export function commonActivate(context: vscode.ExtensionContext, view: ServerMan
vscode.commands.registerCommand(`${extensionId}.editSettings`, (server?: ServerTreeItem) => {
// Attempt to open the correct JSON file
server = server instanceof ServerTreeItem ? server : undefined;
const servers = vscode.workspace.getConfiguration("intersystems").inspect<{ [key: string]: any }>("servers");
const scope: vscode.ConfigurationScope = server?.params?.serverSummary?.scope;
const servers = vscode.workspace.getConfiguration("intersystems", scope).inspect<{ [key: string]: any }>("servers");
const openJSONArg = { revealSetting: { key: "intersystems.servers" } };
const revealServer = (): void => {
// Find the start of the server's settings block
Expand All @@ -191,7 +192,19 @@ export function commonActivate(context: vscode.ExtensionContext, view: ServerMan
}
}
};
if (server && servers?.workspaceValue?.hasOwnProperty(server.name)) {
// Only WorkspaceFolder objects have an index.
if (server && servers?.workspaceFolderValue?.hasOwnProperty(server.name) && typeof (<vscode.WorkspaceFolder>scope)?.index == "number") {
// Open the workspace folder settings file. Need to use showTextDocument because the
// "workbench.action.openFolderSettingsFile" command always prompts the user.
vscode.window.showTextDocument(
vscode.Uri.joinPath((<vscode.WorkspaceFolder>scope).uri, ".vscode", "settings.json"),
// Need these two properties to mimic the workbench commands' behavior
{ preview: false, selection: new vscode.Range(0, 0, 0, 0) }
).then(revealServer, () => {
// If there's an error, fall back to showing the UI
vscode.commands.executeCommand("workbench.action.openSettings", `@ext:${extensionId}`);
});
} else if (server && servers?.workspaceValue?.hasOwnProperty(server.name)) {
// Open the workspace settings file
vscode.commands.executeCommand("workbench.action.openWorkspaceSettingsFile", openJSONArg).then(revealServer);
} else if (server && servers?.globalValue?.hasOwnProperty(server.name)) {
Expand Down
16 changes: 8 additions & 8 deletions src/ui/serverManagerView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class SMTreeItem extends vscode.TreeItem {
public readonly parent: SMTreeItem | undefined;
// tslint:disable-next-line: ban-types
private readonly _getChildren?: Function;
private readonly _params?: any;
public readonly params?: any;

constructor(item: ISMItem) {
const collapsibleState = item.getChildren
Expand All @@ -247,12 +247,12 @@ export class SMTreeItem extends vscode.TreeItem {
this.iconPath = new vscode.ThemeIcon(item.codiconName);
}
this._getChildren = item.getChildren;
this._params = item.params;
this.params = item.params;
}

public async getChildren(): Promise<SMTreeItem[] | undefined> {
if (this._getChildren) {
return await this._getChildren(this, this._params);
return await this._getChildren(this, this.params);
} else {
return;
}
Expand Down Expand Up @@ -280,7 +280,7 @@ async function currentServers(element: SMTreeItem, params?: any): Promise<Server
await Promise.all(workspaceFolders.map(async (folder) => {
const serverName = folder.uri.authority.split(":")[0];
if (["isfs", "isfs-readonly"].includes(folder.uri.scheme)) {
const serverSummary = getServerSummary(serverName);
const serverSummary = getServerSummary(serverName, folder);
if (serverSummary) {
children.set(
serverName,
Expand All @@ -306,7 +306,7 @@ async function currentServers(element: SMTreeItem, params?: any): Promise<Server
}
}
else if (connServer) {
const serverSummary = getServerSummary(connServer);
const serverSummary = getServerSummary(connServer, folder);
if (serverSummary) {
children.set(
connServer,
Expand Down Expand Up @@ -369,7 +369,7 @@ export class ServerTreeItem extends SMTreeItem {
.replace(/[\n\t]/g, " ")
.replace(/[\r\f\b]/g, "")
.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&")
.substr(0, 90)
.slice(0, 90)
.trim();
// Wrap detail (a uri string) as a null link to prevent it from being linkified
const wrappedDetail = `[${serverSummary.detail}]()`;
Expand Down Expand Up @@ -428,12 +428,12 @@ async function serverFeatures(element: ServerTreeItem, params?: any): Promise<Fe
}

async function specFromServerSummary(serverSummary: IServerName): Promise<IServerSpec | undefined> {
const { name, description, detail } = serverSummary;
const { name, description, detail, scope } = serverSummary;
const dockerDetail = detail.match(/^http:\/\/localhost:(\d+)\/$/);
if (dockerDetail) {
return { name, description, webServer: { scheme: "http", host: "127.0.0.1", port: parseInt(dockerDetail[1], 10), pathPrefix: "" } };
}
return getServerSpec(name);
return getServerSpec(name, scope);
}

// tslint:disable-next-line: max-classes-per-file
Expand Down