-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Benjamin Pasero <[email protected]>
Co-authored-by: Benjamin Pasero <[email protected]>
Co-authored-by: Benjamin Pasero <[email protected]>
Co-authored-by: Benjamin Pasero <[email protected]>
@@ -272,6 +288,10 @@ export class ExtHostStatusBarEntry implements vscode.StatusBarItem { | |||
|
|||
public dispose(): void { | |||
this.hide(); | |||
|
|||
this.staticItems.delete(this._entryId); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misses proposed API checks.
No description provided.