status bar - don't leak RPC objects from API (#115679)

This commit is contained in:
Benjamin Pasero 2021-02-03 14:01:09 +01:00
parent 538f72e2a7
commit 376716d1ae
2 changed files with 10 additions and 9 deletions

View file

@ -50,7 +50,6 @@ suite('vscode', function () {
});
test('no rpc, createStatusBarItem(...)', function () {
this.skip();
const item = vscode.window.createStatusBarItem();
dispo.push(item);
assertNoRpcFromEntry([item, 'StatusBarItem']);

View file

@ -18,6 +18,9 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem {
[['statusBarItem.errorBackground', new ThemeColor('statusBarItem.errorForeground')]]
);
#proxy: MainThreadStatusBarShape;
#commands: CommandsConverter;
private _id: number;
private _alignment: number;
private _priority?: number;
@ -38,14 +41,13 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem {
};
private _timeoutHandle: any;
private _proxy: MainThreadStatusBarShape;
private _commands: CommandsConverter;
private _accessibilityInformation?: vscode.AccessibilityInformation;
constructor(proxy: MainThreadStatusBarShape, commands: CommandsConverter, id: string, name: string, alignment: ExtHostStatusBarAlignment = ExtHostStatusBarAlignment.Left, priority?: number, accessibilityInformation?: vscode.AccessibilityInformation) {
this.#proxy = proxy;
this.#commands = commands;
this._id = ExtHostStatusBarEntry.ID_GEN++;
this._proxy = proxy;
this._commands = commands;
this._statusId = id;
this._statusName = name;
this._alignment = alignment;
@ -122,12 +124,12 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem {
if (typeof command === 'string') {
this._command = {
fromApi: command,
internal: this._commands.toInternal({ title: '', command }, this._internalCommandRegistration),
internal: this.#commands.toInternal({ title: '', command }, this._internalCommandRegistration),
};
} else if (command) {
this._command = {
fromApi: command,
internal: this._commands.toInternal(command, this._internalCommandRegistration),
internal: this.#commands.toInternal(command, this._internalCommandRegistration),
};
} else {
this._command = undefined;
@ -148,7 +150,7 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem {
public hide(): void {
clearTimeout(this._timeoutHandle);
this._visible = false;
this._proxy.$dispose(this.id);
this.#proxy.$dispose(this.id);
}
private update(): void {
@ -169,7 +171,7 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem {
}
// Set to status bar
this._proxy.$setEntry(this.id, this._statusId, this._statusName, this._text, this._tooltip, this._command?.internal, color,
this.#proxy.$setEntry(this.id, this._statusId, this._statusName, this._text, this._tooltip, this._command?.internal, color,
this._backgroundColor, this._alignment === ExtHostStatusBarAlignment.Left ? MainThreadStatusBarAlignment.LEFT : MainThreadStatusBarAlignment.RIGHT,
this._priority, this._accessibilityInformation);
}, 0);