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

StatusBarItem - proposed API for async hover #238297

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

lszomoru
Copy link
Member

No description provided.

@lszomoru lszomoru self-assigned this Jan 20, 2025
@lszomoru lszomoru requested a review from bpasero January 20, 2025 14:14
@lszomoru lszomoru changed the title WIP - initial implementation StatusBarItem - proposed API for async hover Jan 20, 2025
@lszomoru lszomoru added the workbench-status Status bar label Jan 20, 2025
@lszomoru lszomoru added this to the January 2025 milestone Jan 20, 2025
@lszomoru lszomoru requested a review from bpasero January 20, 2025 16:04
@@ -272,6 +288,10 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem {

public dispose(): void {
this.hide();

this.staticItems.delete(this._entryId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this: we are not adding to this Map, rather we get it passed in from the outside, so I would not touch this. I think static status bar entries are declared in package.json and can actually not be disposed.

constructor(proxy: MainThreadStatusBarShape, commands: CommandsConverter, staticItems: ReadonlyMap<string, StatusBarItemDto>, extension?: IExtensionDescription, id?: string, alignment: ExtHostStatusBarAlignment = ExtHostStatusBarAlignment.Left, priority?: number) {
constructor(proxy: MainThreadStatusBarShape, commands: CommandsConverter, staticItems: Map<string, StatusBarItemDto>, entries: Map<string, ExtHostStatusBarEntry>, extension: IExtensionDescription, id?: string, alignment?: ExtHostStatusBarAlignment, priority?: number);
constructor(proxy: MainThreadStatusBarShape, commands: CommandsConverter, staticItems: Map<string, StatusBarItemDto>, entries: Map<string, ExtHostStatusBarEntry>, extension: IExtensionDescription | undefined, id: string, alignment?: ExtHostStatusBarAlignment, priority?: number);
constructor(proxy: MainThreadStatusBarShape, commands: CommandsConverter, private staticItems: Map<string, StatusBarItemDto>, private entries: Map<string, ExtHostStatusBarEntry>, extension?: IExtensionDescription, id?: string, alignment: ExtHostStatusBarAlignment = ExtHostStatusBarAlignment.Left, priority?: number) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking staticItems as private gives extensions a way to access this and modify it, I think we cannot do that.

@@ -272,6 +288,10 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem {

public dispose(): void {
this.hide();

this.staticItems.delete(this._entryId);
this.entries.delete(this._entryId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit off: you are passing entries in and even keep it as private (which means extensions could access it) to remove from the dispose. This needs a different, safer approach so that extensions cannot tamper.

return undefined;
}

return MarkdownString.fromStrict(await entry.tooltip2?.(cancellation));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would await the entry.tooltip2 call and then check again for cancellation and then return undefined if cancelled.

@@ -133,6 +139,10 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem {
return this._tooltip;
}

public get tooltip2(): ((token: vscode.CancellationToken) => Promise<string | vscode.MarkdownString | undefined>) | undefined {
return this._tooltip2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misses proposed API checks.

@@ -164,6 +174,11 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem {
this.update();
}

public set tooltip2(tooltip: any) {
this._tooltip2 = tooltip;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misses proposed API checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants