Fixing the error showing up in console log (#23018)

This commit is contained in:
Aasim Khan
2023-05-08 08:29:39 -07:00
committed by GitHub
parent ff3f6d53c7
commit 3ae97b81f2

View File

@@ -33,6 +33,8 @@ import { ILogService } from 'vs/platform/log/common/log';
*/ */
export class ServerTreeActionProvider { export class ServerTreeActionProvider {
private scopedContextService: IContextKeyService;
constructor( constructor(
@IInstantiationService private _instantiationService: IInstantiationService, @IInstantiationService private _instantiationService: IInstantiationService,
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService, @IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
@@ -142,7 +144,6 @@ export class ServerTreeActionProvider {
} }
// Cleanup // Cleanup
scopedContextService.dispose();
menu.dispose(); menu.dispose();
return actions; return actions;
@@ -166,22 +167,28 @@ export class ServerTreeActionProvider {
} }
private getContextKeyService(context: ObjectExplorerContext): IContextKeyService { private getContextKeyService(context: ObjectExplorerContext): IContextKeyService {
let scopedContextService = this._contextKeyService.createScoped(context.tree.getHTMLElement()); if (!this.scopedContextService) {
let connectionContextKey = new ConnectionContextKey(scopedContextService, this._queryManagementService); if (context.tree instanceof AsyncServerTree) {
this.scopedContextService = context.tree.contextKeyService;
} else {
this.scopedContextService = this._contextKeyService.createScoped(context.tree.getHTMLElement());
}
}
let connectionContextKey = new ConnectionContextKey(this.scopedContextService, this._queryManagementService);
let connectionProfile = context && context.profile; let connectionProfile = context && context.profile;
connectionContextKey.set(connectionProfile); connectionContextKey.set(connectionProfile);
let serverInfoContextKey = new ServerInfoContextKey(scopedContextService); let serverInfoContextKey = new ServerInfoContextKey(this.scopedContextService);
if (connectionProfile.id) { if (connectionProfile.id) {
let serverInfo = this._connectionManagementService.getServerInfo(connectionProfile.id); let serverInfo = this._connectionManagementService.getServerInfo(connectionProfile.id);
if (serverInfo) { if (serverInfo) {
serverInfoContextKey.set(serverInfo); serverInfoContextKey.set(serverInfo);
} }
} }
let treeNodeContextKey = new TreeNodeContextKey(scopedContextService, this._capabilitiesService); let treeNodeContextKey = new TreeNodeContextKey(this.scopedContextService, this._capabilitiesService);
if (context.treeNode) { if (context.treeNode) {
treeNodeContextKey.set(context.treeNode); treeNodeContextKey.set(context.treeNode);
} }
return scopedContextService; return this.scopedContextService;
} }
/** /**