@@ -377,8 +377,30 @@ public Task ExecuteCommand(PSCommand psCommand)
377377 /// </summary>
378378 /// <param name="scriptString">The script string to execute.</param>
379379 /// <returns>A Task that can be awaited for the script completion.</returns>
380- public async Task < IEnumerable < object > > ExecuteScriptString ( string scriptString )
380+ public Task < IEnumerable < object > > ExecuteScriptString (
381+ string scriptString )
381382 {
383+ return this . ExecuteScriptString ( scriptString , false ) ;
384+ }
385+
386+ /// <summary>
387+ /// Executes a script string in the session's runspace.
388+ /// </summary>
389+ /// <param name="scriptString">The script string to execute.</param>
390+ /// <param name="writeInputToHost">If true, causes the script string to be written to the host.</param>
391+ /// <returns>A Task that can be awaited for the script completion.</returns>
392+ public async Task < IEnumerable < object > > ExecuteScriptString (
393+ string scriptString ,
394+ bool writeInputToHost )
395+ {
396+ if ( writeInputToHost )
397+ {
398+ ( ( IConsoleHost ) this ) . WriteOutput (
399+ scriptString + Environment . NewLine ,
400+ true ,
401+ OutputType . Normal ) ;
402+ }
403+
382404 PSCommand psCommand = new PSCommand ( ) ;
383405 psCommand . AddScript ( scriptString ) ;
384406
@@ -547,6 +569,14 @@ private void OnSessionStateChanged(object sender, SessionStateChangedEventArgs e
547569
548570 #region Private Methods
549571
572+ private void WriteOutput ( string outputString , bool includeNewLine )
573+ {
574+ ( ( IConsoleHost ) this ) . WriteOutput (
575+ outputString ,
576+ includeNewLine ,
577+ OutputType . Normal ) ;
578+ }
579+
550580 private void WriteExceptionToHost ( Exception e )
551581 {
552582 const string ExceptionFormat =
@@ -867,6 +897,9 @@ private void OnDebuggerStop(object sender, DebuggerStopEventArgs e)
867897
868898 if ( taskIndex == 0 )
869899 {
900+ // Write a new output line before continuing
901+ this . WriteOutput ( "" , true ) ;
902+
870903 e . ResumeAction = this . debuggerStoppedTask . Task . Result ;
871904 Logger . Write ( LogLevel . Verbose , "Received debugger resume action " + e . ResumeAction . ToString ( ) ) ;
872905
0 commit comments