Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;

namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer
{
/// <summary>
/// Defines an event type for PowerShell context execution status changes (e.g. execution has completed)
/// </summary>
public class ExecutionStatusChangedEvent
{
/// <summary>
/// The notification type for execution status change events in the message protocol
/// </summary>
public static readonly
NotificationType<object, object> Type =
NotificationType<object, object>.Create("powerShell/executionStatusChanged");
}
}
14 changes: 14 additions & 0 deletions src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public LanguageServer(
{
this.Logger = logger;
this.editorSession = editorSession;
// Attach to the underlying PowerShell context to listen for changes in the runspace or execution status
this.editorSession.PowerShellContext.RunspaceChanged += PowerShellContext_RunspaceChanged;
this.editorSession.PowerShellContext.ExecutionStatusChanged += PowerShellContext_ExecutionStatusChanged;

// Attach to ExtensionService events
this.editorSession.ExtensionService.CommandAdded += ExtensionService_ExtensionAdded;
Expand Down Expand Up @@ -1273,6 +1275,18 @@ await this.messageSender.SendEvent(
new Protocol.LanguageServer.RunspaceDetails(e.NewRunspace));
}

/// <summary>
/// Event hook on the PowerShell context to listen for changes in script execution status
/// </summary>
/// <param name="sender">the PowerShell context sending the execution event</param>
/// <param name="e">details of the execution status change</param>
private async void PowerShellContext_ExecutionStatusChanged(object sender, ExecutionStatusChangedEventArgs e)
{
await this.messageSender.SendEvent(
ExecutionStatusChangedEvent.Type,
e);
}

private async void ExtensionService_ExtensionAdded(object sender, EditorCommand e)
{
await this.messageSender.SendEvent(
Expand Down