From 8f777226b433d1261cb40682ed8f76b93a62fd03 Mon Sep 17 00:00:00 2001 From: Johannes Date: Wed, 4 Jan 2023 17:36:01 +0100 Subject: [PATCH] don't dispose internal2external commands before updating the UI should fix https://github.com/microsoft/vscode/issues/165244 --- src/vs/workbench/api/common/extHostStatusBar.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/api/common/extHostStatusBar.ts b/src/vs/workbench/api/common/extHostStatusBar.ts index a9076f1e20fbe..412aa06d61b34 100644 --- a/src/vs/workbench/api/common/extHostStatusBar.ts +++ b/src/vs/workbench/api/common/extHostStatusBar.ts @@ -43,7 +43,8 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem { private _name?: string; private _color?: string | ThemeColor; private _backgroundColor?: ThemeColor; - private readonly _internalCommandRegistration = new DisposableStore(); + private _latestCommandRegistration?: DisposableStore; + private readonly _staleCommandRegistrations = new DisposableStore(); private _command?: { readonly fromApi: string | vscode.Command; readonly internal: ICommandDto; @@ -162,16 +163,19 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem { return; } - this._internalCommandRegistration.clear(); + if (this._latestCommandRegistration) { + this._staleCommandRegistrations.add(this._latestCommandRegistration); + } + this._latestCommandRegistration = new DisposableStore(); if (typeof command === 'string') { this._command = { fromApi: command, - internal: this.#commands.toInternal({ title: '', command }, this._internalCommandRegistration), + internal: this.#commands.toInternal({ title: '', command }, this._latestCommandRegistration), }; } else if (command) { this._command = { fromApi: command, - internal: this.#commands.toInternal(command, this._internalCommandRegistration), + internal: this.#commands.toInternal(command, this._latestCommandRegistration), }; } else { this._command = undefined; @@ -240,6 +244,9 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem { this.#proxy.$setEntry(this._entryId, id, name, this._text, tooltip, this._command?.internal, color, this._backgroundColor, this._alignment === ExtHostStatusBarAlignment.Left, this._priority, this._accessibilityInformation); + + // clean-up state commands _after_ updating the UI + this._staleCommandRegistrations.clear(); }, 0); }