MarkdownString for StatusBarItem.tooltip. For #126258

This commit is contained in:
Martin Aeschlimann
2021-06-15 15:17:12 +02:00
parent e22ee0920a
commit 6c4230e86c
4 changed files with 29 additions and 3 deletions

View File

@@ -11,6 +11,7 @@ import { localize } from 'vs/nls';
import { CommandsConverter } from 'vs/workbench/api/common/extHostCommands';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { MarkdownString } from 'vs/workbench/api/common/extHostTypeConverters';
export class ExtHostStatusBarEntry implements vscode.StatusBarItem {
@@ -36,6 +37,7 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem {
private _text: string = '';
private _tooltip?: string;
private _tooltip2?: vscode.MarkdownString | string;
private _name?: string;
private _color?: string | ThemeColor;
private _backgroundColor?: ThemeColor;
@@ -87,6 +89,10 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem {
return this._tooltip;
}
public get tooltip2(): string | vscode.MarkdownString | undefined {
return this._tooltip2;
}
public get color(): string | ThemeColor | undefined {
return this._color;
}
@@ -118,6 +124,11 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem {
this.update();
}
public set tooltip2(tooltip: vscode.MarkdownString | string | undefined) {
this._tooltip2 = tooltip;
this.update();
}
public set color(color: string | ThemeColor | undefined) {
this._color = color;
this.update();
@@ -209,8 +220,10 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem {
color = ExtHostStatusBarEntry.ALLOWED_BACKGROUND_COLORS.get(this._backgroundColor.id);
}
const tooltip = this._tooltip2 !== undefined ? MarkdownString.fromStrict(this._tooltip2) : this.tooltip;
// Set to status bar
this.#proxy.$setEntry(this._entryId, id, name, this._text, this._tooltip, this._command?.internal, color,
this.#proxy.$setEntry(this._entryId, id, name, this._text, tooltip, this._command?.internal, color,
this._backgroundColor, this._alignment === ExtHostStatusBarAlignment.Left ? MainThreadStatusBarAlignment.LEFT : MainThreadStatusBarAlignment.RIGHT,
this._priority, this._accessibilityInformation);
}, 0);