Skip to content

Commit 7c940e2

Browse files
authored
Merge pull request #184 from intersystems-community/explorer-view-multi
fixed extra namespaces per instance in explorer view
2 parents 65bad4e + 739203e commit 7c940e2

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/explorer/explorer.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,40 @@ export class ObjectScriptExplorerProvider implements vscode.TreeDataProvider<Nod
99
public onDidChange?: vscode.Event<vscode.Uri>;
1010
public onDidChangeTreeData: vscode.Event<NodeBase>;
1111
private _onDidChangeTreeData: vscode.EventEmitter<NodeBase>;
12-
private _showExtra4Workspace: string[] = [];
12+
private _showExtra4Workspace: { [key: string]: string[] }[] = [];
1313

1414
public constructor() {
1515
this._onDidChangeTreeData = new vscode.EventEmitter<NodeBase>();
1616
this.onDidChangeTreeData = this._onDidChangeTreeData.event;
1717
}
1818

1919
public async selectNamespace(workspaceFolder: string): Promise<any> {
20+
const extra4Workspace = this._showExtra4Workspace[workspaceFolder] || [];
2021
const api = new AtelierAPI(workspaceFolder);
2122
return api
2223
.serverInfo()
2324
.then((data) => data.result.content.namespaces)
24-
.then((data) => data.filter((ns) => ns !== api.ns && !this._showExtra4Workspace.includes(ns)))
25+
.then((data) => data.filter((ns) => ns !== api.ns && !extra4Workspace.includes(ns)))
2526
.then((data) => data.map((ns) => ({ label: ns })))
2627
.then(vscode.window.showQuickPick)
2728
.then((ns) => this.showExtra4Workspace(workspaceFolder, ns.label));
2829
}
2930

30-
public showExtra4Workspace(workspaceFolder: string, ns: string) {
31-
if (!this._showExtra4Workspace.includes(ns)) {
32-
this._showExtra4Workspace.push(ns);
31+
public showExtra4Workspace(workspaceFolder: string, ns: string): void {
32+
const extra4Workspace = this._showExtra4Workspace[workspaceFolder] || [];
33+
if (!extra4Workspace.includes(ns)) {
34+
extra4Workspace.push(ns);
35+
this._showExtra4Workspace[workspaceFolder] = extra4Workspace;
3336
this._onDidChangeTreeData.fire(null);
3437
}
3538
}
3639

37-
public closeExtra4Workspace(workspaceFolder: string, ns: string) {
38-
const pos = this._showExtra4Workspace.indexOf(ns);
40+
public closeExtra4Workspace(workspaceFolder: string, ns: string): void {
41+
const extra4Workspace = this._showExtra4Workspace[workspaceFolder] || [];
42+
const pos = extra4Workspace.indexOf(ns);
3943
if (pos >= 0) {
40-
this._showExtra4Workspace.splice(pos, 1);
44+
extra4Workspace.splice(pos, 1);
45+
this._showExtra4Workspace[workspaceFolder] = extra4Workspace;
4146
this._onDidChangeTreeData.fire(null);
4247
}
4348
}
@@ -67,10 +72,11 @@ export class ObjectScriptExplorerProvider implements vscode.TreeDataProvider<Nod
6772
.forEach((workspaceFolder) => {
6873
const conn: any = config("conn", workspaceFolder.name);
6974
if (conn.active && conn.ns) {
75+
const extra4Workspace = this._showExtra4Workspace[workspaceFolder.name] || [];
7076
node = new WorkspaceNode(workspaceFolder.name, this._onDidChangeTreeData, {});
7177
rootNodes.push(node);
7278

73-
this._showExtra4Workspace.forEach((ns) => {
79+
extra4Workspace.forEach((ns) => {
7480
node = new WorkspaceNode(workspaceFolder.name, this._onDidChangeTreeData, {
7581
namespace: ns,
7682
extraNode: true,

0 commit comments

Comments
 (0)