Skip to content

Commit 874a0c8

Browse files
committed
Improve newline output in command prompt loop
1 parent 5984049 commit 874a0c8

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/PowerShellEditorServices/Session/Host/EditorServicesPSHostUserInterface.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,8 +720,6 @@ private async Task StartReplLoop(CancellationToken cancellationToken)
720720

721721
if (commandString != null)
722722
{
723-
this.WriteOutput(string.Empty);
724-
725723
if (!string.IsNullOrWhiteSpace(commandString))
726724
{
727725
var unusedTask =
@@ -735,6 +733,10 @@ private async Task StartReplLoop(CancellationToken cancellationToken)
735733

736734
break;
737735
}
736+
else
737+
{
738+
this.WriteOutput(string.Empty);
739+
}
738740
}
739741
}
740742
while (!cancellationToken.IsCancellationRequested);

src/PowerShellEditorServices/Session/PowerShellContext.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,11 +715,12 @@ public async Task<IEnumerable<object>> ExecuteScriptString(
715715
bool writeOutputToHost,
716716
bool addToHistory)
717717
{
718+
// Get rid of leading and trailing whitespace and newlines
719+
scriptString = scriptString.Trim();
720+
718721
if (writeInputToHost)
719722
{
720-
this.WriteOutput(
721-
scriptString + Environment.NewLine,
722-
true);
723+
this.WriteOutput(scriptString, false);
723724
}
724725

725726
PSCommand psCommand = new PSCommand();

0 commit comments

Comments
 (0)