MarkdownString for StatusBarItem.tooltip. For #126258
This commit is contained in:
parent
0a0c8f3d2a
commit
5b79dcf94a
4 changed files with 29 additions and 3 deletions
12
src/vs/vscode.proposed.d.ts
vendored
12
src/vs/vscode.proposed.d.ts
vendored
|
@ -2872,4 +2872,16 @@ declare module 'vscode' {
|
|||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region https://github.com/microsoft/vscode/issues/126258 @aeschli
|
||||
|
||||
export interface StatusBarItem {
|
||||
|
||||
/**
|
||||
* Will be merged into StatusBarItem#tooltip
|
||||
*/
|
||||
tooltip2: string | MarkdownString | undefined;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import { dispose } from 'vs/base/common/lifecycle';
|
|||
import { Command } from 'vs/editor/common/modes';
|
||||
import { IAccessibilityInformation } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { getCodiconAriaLabel } from 'vs/base/common/codicons';
|
||||
import { IMarkdownString } from 'vs/base/common/htmlContent';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadStatusBar)
|
||||
export class MainThreadStatusBar implements MainThreadStatusBarShape {
|
||||
|
@ -27,7 +28,7 @@ export class MainThreadStatusBar implements MainThreadStatusBarShape {
|
|||
this.entries.clear();
|
||||
}
|
||||
|
||||
$setEntry(entryId: number, id: string, name: string, text: string, tooltip: string | undefined, command: Command | undefined, color: string | ThemeColor | undefined, backgroundColor: string | ThemeColor | undefined, alignment: MainThreadStatusBarAlignment, priority: number | undefined, accessibilityInformation: IAccessibilityInformation): void {
|
||||
$setEntry(entryId: number, id: string, name: string, text: string, tooltip: IMarkdownString | string | undefined, command: Command | undefined, color: string | ThemeColor | undefined, backgroundColor: string | ThemeColor | undefined, alignment: MainThreadStatusBarAlignment, priority: number | undefined, accessibilityInformation: IAccessibilityInformation): void {
|
||||
// if there are icons in the text use the tooltip for the aria label
|
||||
let ariaLabel: string;
|
||||
let role: string | undefined = undefined;
|
||||
|
|
|
@ -595,7 +595,7 @@ export interface MainThreadQuickOpenShape extends IDisposable {
|
|||
}
|
||||
|
||||
export interface MainThreadStatusBarShape extends IDisposable {
|
||||
$setEntry(id: number, statusId: string, statusName: string, text: string, tooltip: string | undefined, command: ICommandDto | undefined, color: string | ThemeColor | undefined, backgroundColor: string | ThemeColor | undefined, alignment: statusbar.StatusbarAlignment, priority: number | undefined, accessibilityInformation: IAccessibilityInformation | undefined): void;
|
||||
$setEntry(id: number, statusId: string, statusName: string, text: string, tooltip: IMarkdownString | string | undefined, command: ICommandDto | undefined, color: string | ThemeColor | undefined, backgroundColor: string | ThemeColor | undefined, alignment: statusbar.StatusbarAlignment, priority: number | undefined, accessibilityInformation: IAccessibilityInformation | undefined): void;
|
||||
$dispose(id: number): void;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue