PowerShellEditorServices icon indicating copy to clipboard operation
PowerShellEditorServices copied to clipboard

$psEditor.Window.ShowErrorMessage never returns

Open SeeminglyScience opened this issue 6 years ago • 4 comments

Steps

  1. In the integrated console run $psEditor.Window.ShowErrorMessage('test')
  2. Do not click the X on the notifcation, instead click anywhere in the body and press escape.

Expected

The notification to be dismissed and the prompt to return.

Actual

The notification is dismissed, but the prompt never returns. ShowErrorMessage blocks the pipeline indefinitely.

Notes

The pipeline completes if the X is clicked instead. All that said, I don't think it should ever wait for completion. It feels real bad, especially from editor commands, to require dismissing the notification to free up the pipeline thread.

SeeminglyScience avatar Nov 18 '19 17:11 SeeminglyScience

. All that said, I don't think it should ever wait for completion.

I think that's been the behavior for a while now and I totally agree with you. It should be a notification, not a request expecting a response.

TylerLeonhardt avatar Nov 18 '19 19:11 TylerLeonhardt

. All that said, I don't think it should ever wait for completion.

I think that's been the behavior for a while now

Yeah I was bypassing it by sending the message directly with the old IMessageSender, since it had a general waitForResponse parameter. New one doesn't have a way to do that afaict though.

SeeminglyScience avatar Nov 18 '19 19:11 SeeminglyScience

https://github.com/PowerShell/PowerShellEditorServices/blob/master/src/PowerShellEditorServices/Services/PowerShellContext/EditorOperationsService.cs#L159-L180

A simple change. Instead of SendRequest it's SendNotification

Then in vscode-powershell change these to NotificationType: https://github.com/PowerShell/vscode-powershell/blob/master/src/features/ExtensionCommands.ts#L142-L156

And change onRequest to onNotification https://github.com/PowerShell/vscode-powershell/blob/master/src/features/ExtensionCommands.ts#L253-L267

TylerLeonhardt avatar Nov 19 '19 04:11 TylerLeonhardt

I think I'm just gonna use window/showMessage directly actually. Still a good change to make though.

SeeminglyScience avatar Nov 19 '19 13:11 SeeminglyScience