File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
src/PowerShellEditorServices.Protocol Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ using Microsoft . PowerShell . EditorServices . Protocol . MessageProtocol ;
2+
3+ namespace Microsoft . PowerShell . EditorServices . Protocol . LanguageServer
4+ {
5+ /// <summary>
6+ /// Defines an event type for PowerShell context execution status changes (e.g. execution has completed)
7+ /// </summary>
8+ public class ExecutionStatusChangedEvent
9+ {
10+ /// <summary>
11+ /// The notification type for execution status change events in the message protocol
12+ /// </summary>
13+ public static readonly
14+ NotificationType < object , object > Type =
15+ NotificationType < object , object > . Create ( "powerShell/executionStatusChanged" ) ;
16+ }
17+ }
Original file line number Diff line number Diff line change @@ -56,7 +56,9 @@ public LanguageServer(
5656 {
5757 this . Logger = logger ;
5858 this . editorSession = editorSession ;
59+ // Attach to the underlying PowerShell context to listen for changes in the runspace or execution status
5960 this . editorSession . PowerShellContext . RunspaceChanged += PowerShellContext_RunspaceChanged ;
61+ this . editorSession . PowerShellContext . ExecutionStatusChanged += PowerShellContext_ExecutionStatusChanged ;
6062
6163 // Attach to ExtensionService events
6264 this . editorSession . ExtensionService . CommandAdded += ExtensionService_ExtensionAdded ;
@@ -1273,6 +1275,18 @@ await this.messageSender.SendEvent(
12731275 new Protocol . LanguageServer . RunspaceDetails ( e . NewRunspace ) ) ;
12741276 }
12751277
1278+ /// <summary>
1279+ /// Event hook on the PowerShell context to listen for changes in script execution status
1280+ /// </summary>
1281+ /// <param name="sender">the PowerShell context sending the execution event</param>
1282+ /// <param name="e">details of the execution status change</param>
1283+ private async void PowerShellContext_ExecutionStatusChanged ( object sender , ExecutionStatusChangedEventArgs e )
1284+ {
1285+ await this . messageSender . SendEvent (
1286+ ExecutionStatusChangedEvent . Type ,
1287+ e ) ;
1288+ }
1289+
12761290 private async void ExtensionService_ExtensionAdded ( object sender , EditorCommand e )
12771291 {
12781292 await this . messageSender . SendEvent (
You can’t perform that action at this time.
0 commit comments