Skip to content

Commit

Permalink
Allow panel names to be re-used on different servers. (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed Aug 8, 2024
1 parent 1319dc2 commit 688d399
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function activate(context: vscode.ExtensionContext) {

const dhcServiceRegistry = new DhServiceRegistry(
DhcService,
new ExtendedMap<string, vscode.WebviewPanel>(),
new ExtendedMap<string, ExtendedMap<string, vscode.WebviewPanel>>(),
diagnosticsCollection,
outputChannel,
toaster
Expand Down
13 changes: 11 additions & 2 deletions src/services/DhServiceRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export class DhServiceRegistry<T extends DhcService> extends CacheService<
> {
constructor(
serviceFactory: DhServiceConstructor<T>,
panelRegistry: ExtendedMap<string, vscode.WebviewPanel>,
panelRegistry: ExtendedMap<
string,
ExtendedMap<string, vscode.WebviewPanel>
>,
diagnosticsCollection: vscode.DiagnosticCollection,
outputChannel: vscode.OutputChannel,
toaster: Toaster
Expand All @@ -22,9 +25,15 @@ export class DhServiceRegistry<T extends DhcService> extends CacheService<
throw new Error(`${serviceFactory.name} server url is null.`);
}

// Get or add the panel registry for the server if it doesn't exist.
if (!panelRegistry.has(serverUrl)) {
panelRegistry.set(serverUrl, new ExtendedMap());
}
const serverPanelRegistry = panelRegistry.getOrThrow(serverUrl);

const dhService = new serviceFactory(
serverUrl,
panelRegistry,
serverPanelRegistry,
diagnosticsCollection,
outputChannel,
toaster
Expand Down

0 comments on commit 688d399

Please sign in to comment.