diff --git a/src/PowerShellEditorServices/Debugging/StackFrameDetails.cs b/src/PowerShellEditorServices/Debugging/StackFrameDetails.cs index d228a32bf..fe4a24f32 100644 --- a/src/PowerShellEditorServices/Debugging/StackFrameDetails.cs +++ b/src/PowerShellEditorServices/Debugging/StackFrameDetails.cs @@ -64,7 +64,7 @@ static internal StackFrameDetails Create( { return new StackFrameDetails { - ScriptPath = callStackFrame.ScriptName, + ScriptPath = callStackFrame.ScriptName ?? "", FunctionName = callStackFrame.FunctionName, LineNumber = callStackFrame.Position.StartLineNumber, ColumnNumber = callStackFrame.Position.StartColumnNumber, diff --git a/src/PowerShellEditorServices/Session/PowerShellContext.cs b/src/PowerShellEditorServices/Session/PowerShellContext.cs index d869e57e0..d0aa07666 100644 --- a/src/PowerShellEditorServices/Session/PowerShellContext.cs +++ b/src/PowerShellEditorServices/Session/PowerShellContext.cs @@ -455,18 +455,22 @@ public async Task> ExecuteScriptString( /// A Task that can be awaited for completion. public async Task ExecuteScriptAtPath(string scriptPath, string arguments = null) { - // If we don't escape wildcard characters in the script path, the script can - // fail to execute if say the script name was foo][.ps1. - // Related to issue #123. - string escapedScriptPath = EscapePath(scriptPath, escapeSpaces: true); + PSCommand command = new PSCommand(); if (arguments != null) { - escapedScriptPath += " " + arguments; - } + // If we don't escape wildcard characters in the script path, the script can + // fail to execute if say the script name was foo][.ps1. + // Related to issue #123. + string escapedScriptPath = EscapePath(scriptPath, escapeSpaces: true); + string scriptWithArgs = escapedScriptPath + " " + arguments; - PSCommand command = new PSCommand(); - command.AddScript(escapedScriptPath); + command.AddScript(scriptWithArgs); + } + else + { + command.AddCommand(scriptPath); + } await this.ExecuteCommand(command, true); }