Skip to content

Commit 3c1e119

Browse files
committed
Merge pull request #156 from rkeithhill/rkeithhill/addscript-extra-stackframe
Fixes #155 - selecting outermost scope crashes debug host.
2 parents dda82dc + a2e206c commit 3c1e119

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/PowerShellEditorServices/Debugging/StackFrameDetails.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static internal StackFrameDetails Create(
6464
{
6565
return new StackFrameDetails
6666
{
67-
ScriptPath = callStackFrame.ScriptName,
67+
ScriptPath = callStackFrame.ScriptName ?? "<No File>",
6868
FunctionName = callStackFrame.FunctionName,
6969
LineNumber = callStackFrame.Position.StartLineNumber,
7070
ColumnNumber = callStackFrame.Position.StartColumnNumber,

src/PowerShellEditorServices/Session/PowerShellContext.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -455,18 +455,22 @@ public async Task<IEnumerable<object>> ExecuteScriptString(
455455
/// <returns>A Task that can be awaited for completion.</returns>
456456
public async Task ExecuteScriptAtPath(string scriptPath, string arguments = null)
457457
{
458-
// If we don't escape wildcard characters in the script path, the script can
459-
// fail to execute if say the script name was foo][.ps1.
460-
// Related to issue #123.
461-
string escapedScriptPath = EscapePath(scriptPath, escapeSpaces: true);
458+
PSCommand command = new PSCommand();
462459

463460
if (arguments != null)
464461
{
465-
escapedScriptPath += " " + arguments;
466-
}
462+
// If we don't escape wildcard characters in the script path, the script can
463+
// fail to execute if say the script name was foo][.ps1.
464+
// Related to issue #123.
465+
string escapedScriptPath = EscapePath(scriptPath, escapeSpaces: true);
466+
string scriptWithArgs = escapedScriptPath + " " + arguments;
467467

468-
PSCommand command = new PSCommand();
469-
command.AddScript(escapedScriptPath);
468+
command.AddScript(scriptWithArgs);
469+
}
470+
else
471+
{
472+
command.AddCommand(scriptPath);
473+
}
470474

471475
await this.ExecuteCommand<object>(command, true);
472476
}

0 commit comments

Comments
 (0)