Skip to content

Track tempIntegratedConsole launch param, do not exit when session ends #625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2018
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
6 changes: 6 additions & 0 deletions src/PowerShellEditorServices.Host/EditorServicesHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@ private void OnDebugServiceClientConnect(object sender, TcpSocketServerChannel s

this.debugServiceListener.Start();
}
else if (this.debugAdapter.IsUsingTempIntegratedConsole)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this else if prevents the host from exiting... What's the host in this case?

More simply, what is the user experience change?

Copy link
Contributor Author

@rkeithhill rkeithhill Feb 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The temp debug console does not immediately exit after the script finishes execution or the debug session is stopped. This allows the user to scroll through the window to inspect the script output.

The only downside I've observed at this point is that every temp debug session log file ends with:

2/19/2018 8:48:16 PM [ERROR] - Method "ListenForMessages" at line 344 of C:\Users\Keith\GitHub\rkeithhill\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs

    Stream terminated unexpectedly, ending MessageDispatcher loop
    
    Exception: IOException
    Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

This is because VSCode does terminate the process when it starts the next debug session. All things considered, I think this is a fine trade-off.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100% agree!

{
this.logger.Write(
LogLevel.Normal,
"Previous temp debug session ended");
}
else
{
// Exit the host process
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ public class LaunchRequestArguments
/// </summary>
public string Cwd { get; set; }

/// <summary>
/// Gets or sets a boolean value that determines whether to create a temporary
/// integrated console for the debug session. Default is false.
/// </summary>
public bool CreateTemporaryIntegratedConsole { get; set; }

/// <summary>
/// Gets or sets the absolute path to the runtime executable to be used.
/// Default is the runtime executable on the PATH.
Expand Down
7 changes: 7 additions & 0 deletions src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public DebugAdapter(
this.ownsEditorSession = ownsEditorSession;
}

/// <summary>
/// Gets a boolean that indicates whether the current debug adapter is
/// using a temporary integrated console.
/// </summary>
public bool IsUsingTempIntegratedConsole { get; private set; }

public void Start()
{
// Register all supported message types
Expand Down Expand Up @@ -313,6 +319,7 @@ protected async Task HandleLaunchRequest(
this.scriptToLaunch = launchParams.Script ?? launchParams.Program;
#pragma warning restore 618
this.arguments = arguments;
this.IsUsingTempIntegratedConsole = launchParams.CreateTemporaryIntegratedConsole;

// If the current session is remote, map the script path to the remote
// machine if necessary
Expand Down