Add an option to dismiss notifications with ESC instead of minimizing them
See original GitHub issueI had always thought that pressing ESC had the same behavior as clicking the ‘x’ for the popup “toast” messages, but while investigating an issue with missing telemetry for an experiment we’re doing in CMake Tools, I discovered that pressing ESC after calling vscode.window.showErrorMessage
didn’t return a result back to our code nor did it reject the promise. The code just sat there until we shut down the extension host window.
This morning I had a thought that maybe the message had been minimized, and sure enough that’s what it was. This is a problem for extensions that want to log telemetry as a result of a dismissal. Can we get an option in the API to make pressing ESC behave the same as clicking the ‘x’ button in certain toast messages?
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:19 (19 by maintainers)
Top GitHub Comments
I think we all agree with not changing the default behaviour, it’s more about providing an option to extensions to be able to do something when users press ESC. For example, I have a custom extension with the following code:
When users close the notification,
selection
getsundefined
. But if they press ESC, nothing ever happens (and I think this is what @bobbrow meant by “the code just sat there until we shut down the extension host window.”)@bobbrow thanks for filling the issue. Great discussion. I agree with @digitarald and @daviddossett as that seems like a cleaner solution for this use case.
However with the current API the C++ extension can not do this. Since the
showMessage
API resolves a promise only once a user dismisses it or chooses a button. So there is not way for an extension to listen to when the user hides all notifications.fyi @luabud might have ideas on how an extension can figure out if the user hid a notification for experiment purposes.
@bpasero might also have ideas once he returns (in around 2 weeks)