Skip to content

Commit 3fbd436

Browse files
committed
Print launched script and args to host in DebugAdapter
1 parent 99750ef commit 3fbd436

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected Task LaunchScript(RequestContext<object> requestContext)
101101
this.editorSession.ConsoleService.CancelReadLoop();
102102

103103
return editorSession.PowerShellContext
104-
.ExecuteScriptWithArgs(this.scriptToLaunch, this.arguments)
104+
.ExecuteScriptWithArgs(this.scriptToLaunch, this.arguments, writeInputToHost: true)
105105
.ContinueWith(this.OnExecutionCompleted);
106106
}
107107

src/PowerShellEditorServices/Session/PowerShellContext.cs

+13-3
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,11 @@ await this.ExecuteCommand<object>(
668668
/// </summary>
669669
/// <param name="script">The script execute.</param>
670670
/// <param name="arguments">Arguments to pass to the script.</param>
671+
/// <param name="writeInputToHost">Writes the executed script path and arguments to the host.</param>
671672
/// <returns>A Task that can be awaited for completion.</returns>
672-
public async Task ExecuteScriptWithArgs(string script, string arguments = null)
673+
public async Task ExecuteScriptWithArgs(string script, string arguments = null, bool writeInputToHost = false)
673674
{
675+
string launchedScript = script;
674676
PSCommand command = new PSCommand();
675677

676678
if (arguments != null)
@@ -699,14 +701,22 @@ public async Task ExecuteScriptWithArgs(string script, string arguments = null)
699701
{
700702
script = EscapePath(script, escapeSpaces: true);
701703
}
702-
string scriptWithArgs = script + " " + arguments;
703-
command.AddScript(scriptWithArgs);
704+
705+
launchedScript = script + " " + arguments;
706+
command.AddScript(launchedScript);
704707
}
705708
else
706709
{
707710
command.AddCommand(script);
708711
}
709712

713+
if (writeInputToHost)
714+
{
715+
this.WriteOutput(
716+
launchedScript + Environment.NewLine,
717+
true);
718+
}
719+
710720
await this.ExecuteCommand<object>(
711721
command,
712722
null,

0 commit comments

Comments
 (0)