Skip to content

Commit ab1e555

Browse files
committed
WIP
1 parent 7c9a68d commit ab1e555

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

src/PowerShellEditorServices/Debugging/DebugService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ public async Task<BreakpointDetails[]> SetBreakpoints(
7979
{
8080
// Fix for issue #123 - file paths that contain wildcard chars [ and ] need to
8181
// quoted and have those wildcard chars escaped.
82-
string escapedScriptPath = PowerShellContext.EscapeWildcardsInPath(scriptFile.FilePath);
82+
string escapedScriptPath =
83+
PowerShellContext.EscapePath(scriptFile.FilePath, escapeSpaces: false);
8384

8485
PSCommand psCommand = new PSCommand();
8586
psCommand.AddCommand("Set-PSBreakpoint");

src/PowerShellEditorServices/Session/PowerShellContext.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ public async Task ExecuteScriptAtPath(string scriptPath, string arguments = null
457457
// If we don't escape wildcard characters in the script path, the script can
458458
// fail to execute if say the script name was foo][.ps1.
459459
// Related to issue #123.
460-
string escapedScriptPath = EscapeWildcardsInPath(scriptPath);
460+
string escapedScriptPath = EscapePath(scriptPath, escapeSpaces: true);
461461

462462
if (arguments != null)
463463
{
@@ -577,13 +577,21 @@ internal void ReleaseRunspaceHandle(RunspaceHandle runspaceHandle)
577577
}
578578

579579
/// <summary>
580-
/// Returns the passed in path with the [ and ] wildcard characters escaped.
580+
/// Returns the passed in path with the [ and ] characters escaped. Escaping spaces is optional.
581581
/// </summary>
582582
/// <param name="path">The path to process.</param>
583+
/// <param name="escapeSpaces">Specify True to escape spaces in the path, otherwise False.</param>
583584
/// <returns>The path with [ and ] escaped.</returns>
584-
internal static string EscapeWildcardsInPath(string path)
585+
internal static string EscapePath(string path, bool escapeSpaces)
585586
{
586-
return path.Replace("[", "`[").Replace("]", "`]");
587+
string escapedPath = path.Replace("[", "`[").Replace("]", "`]");
588+
589+
if (escapeSpaces)
590+
{
591+
escapedPath = escapedPath.Replace(" ", "` ");
592+
}
593+
594+
return escapedPath;
587595
}
588596

589597
#endregion

test/PowerShellEditorServices.Test.Shared/PowerShellEditorServices.Test.Shared.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<None Include="Completion\CompletionExamples.psm1">
6565
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
6666
</None>
67-
<None Include="Debugging\DebugWithParamsTest.ps1" />
67+
<None Include="Debugging\Debug With Params [Test].ps1" />
6868
<None Include="Debugging\VariableTest.ps1" />
6969
<None Include="SymbolDetails\SymbolDetails.ps1" />
7070
<None Include="Symbols\MultipleSymbols.ps1" />

test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public async Task DebuggerAcceptsScriptArgs(string[] args)
8989
{
9090
ScriptFile debugWithParamsFile =
9191
this.workspace.GetFile(
92-
@"..\..\..\PowerShellEditorServices.Test.Shared\Debugging\DebugWithParamsTest.ps1");
92+
@"..\..\..\PowerShellEditorServices.Test.Shared\Debugging\Debug With Params [Test].ps1");
9393

9494
await this.debugService.SetBreakpoints(
9595
debugWithParamsFile,

0 commit comments

Comments
 (0)