-
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
Implement modal message API #19717
Implement modal message API #19717
Conversation
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.
👍
function parseMessageArguments(args: any[]): { options: vscode.MessageOptions; items: any[]; } { | ||
const [first, ...rest] = args; | ||
|
||
if (first && (typeof first === 'string' || first.title)) { |
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.
What if first === ''
? The first check would fail even though it is a string
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.
great catch
@@ -58,4 +67,27 @@ export class MainThreadMessageService extends MainThreadMessageServiceShape { | |||
}); | |||
}); | |||
} | |||
|
|||
private showModalMessage(severity: Severity, message: string, commands: { title: string; isCloseAffordance: boolean; handle: number; }[]): Thenable<number> { | |||
let closeAffordanceIndex = -1; |
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.
Just keep a boolean
? I do not see closeAffordanceIndex
being used for anything but that. Or is that an oversight?
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.
Leftover...
Pushed changes. |
} else { | ||
return { options: first || emptyMessageOptions, items: rest }; | ||
} | ||
} |
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 like the code but I don't like that it is placed here. Instead I'd propose to move it into the extHostMessageService
and make its showMessage
-function like: showMessage(sev, message, optionOrFirstItem, ...restItem)
. That would encapsulate things better IMO
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.
Not entirely convinced. Made rest not a spread param. Pushed for extra review.
* Indicates that this message should be modal. | ||
*/ | ||
modal?: boolean; | ||
} |
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.
Can we already imagine having other options here? If not we should think about a naked boolean instead
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.
Timeout, icon?
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 prefer option bags simply because it is so easy to add stuff to them later without having yet another overload. Also, there is a lot more you can do in electron dialog API (for example master/detail message) and we could also revisit our message UI to support them eventually.
ok to 🚢 tho I don't understand the backticks? |
Even though this is scheduled for the February milestone it doesn't seem to be available in the April update yet. I installed the latest vscode.d.ts but still there is no message options yet. Has this been missed, replanned or am I doing something wrong? |
Related to #18790