From 68850df306468110d4791d0ba98169e13ac15ec6 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Sat, 9 Nov 2019 21:08:13 -0500 Subject: [PATCH 1/3] fix running indicator by ignoring PSRL aborts --- .../PowerShellContext/PowerShellContextService.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs b/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs index 3f1a03c32..1bb587994 100644 --- a/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs +++ b/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs @@ -1838,9 +1838,15 @@ public MinifiedRunspaceDetails(RunspaceDetails eventArgs) /// details of the execution status change private void PowerShellContext_ExecutionStatusChangedAsync(object sender, ExecutionStatusChangedEventArgs e) { - _languageServer?.SendNotification( - "powerShell/executionStatusChanged", - e); + // The cancelling of the prompt (PSReadLine) causes an ExecutionStatus.Aborted to be sent after every + // actual execution (ExecutionStatus.Running) on the pipeline. We ignore that event since it's counterintuitive to + // the goal of this method which is to send updates when the pipeline is actually running something. + if (!e?.ExecutionOptions?.IsReadLine ?? true) + { + _languageServer?.SendNotification( + "powerShell/executionStatusChanged", + e); + } } #endregion From f2a205af2b26deabecd29583a3fcc90c3afda2bc Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Sun, 10 Nov 2019 00:08:43 -0500 Subject: [PATCH 2/3] added comment on default --- .../Services/PowerShellContext/PowerShellContextService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs b/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs index 1bb587994..91f8c90a6 100644 --- a/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs +++ b/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs @@ -1841,6 +1841,7 @@ private void PowerShellContext_ExecutionStatusChangedAsync(object sender, Execut // The cancelling of the prompt (PSReadLine) causes an ExecutionStatus.Aborted to be sent after every // actual execution (ExecutionStatus.Running) on the pipeline. We ignore that event since it's counterintuitive to // the goal of this method which is to send updates when the pipeline is actually running something. + // In the event that we don't know if it was a ReadLine cancel, we default to sending the notification. if (!e?.ExecutionOptions?.IsReadLine ?? true) { _languageServer?.SendNotification( From cd374a85d5acaf1c512ae39726c710cfcce5b1a4 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 12 Nov 2019 09:19:34 -0800 Subject: [PATCH 3/3] clearer logic --- .../Services/PowerShellContext/PowerShellContextService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs b/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs index 1bb587994..fede4682a 100644 --- a/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs +++ b/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs @@ -1841,7 +1841,8 @@ private void PowerShellContext_ExecutionStatusChangedAsync(object sender, Execut // The cancelling of the prompt (PSReadLine) causes an ExecutionStatus.Aborted to be sent after every // actual execution (ExecutionStatus.Running) on the pipeline. We ignore that event since it's counterintuitive to // the goal of this method which is to send updates when the pipeline is actually running something. - if (!e?.ExecutionOptions?.IsReadLine ?? true) + var options = e?.ExecutionOptions; + if (options == null || !options.IsReadLine) { _languageServer?.SendNotification( "powerShell/executionStatusChanged",