Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't dispose internal2external commands before updating the UI #170566

Merged
merged 1 commit into from
Jan 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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