Skip to content

Commit

Permalink
don't dispose internal2external commands before updating the UI (#170566
Browse files Browse the repository at this point in the history
)

should fix #165244
  • Loading branch information
jrieken committed Jan 4, 2023
1 parent fb26225 commit b4b9972
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/vs/workbench/api/common/extHostStatusBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit b4b9972

Please sign in to comment.