From 86aa91c96ff9351b747418943c607a50622d323e Mon Sep 17 00:00:00 2001 From: Andy Jordan Date: Wed, 2 Nov 2022 12:07:57 -0700 Subject: [PATCH] Wrap script paths with single instead of double quotes In order to support funny path names with dollar signs. Also this is what PowerShell does by default (e.g. through tab-completion). --- .../Commands/StartEditorServicesCommand.cs | 2 +- .../DebugAdapter/Handlers/ConfigurationDoneHandler.cs | 2 +- .../DebugAdapterProtocolMessageTests.cs | 2 +- .../Debugging/DebugServiceTests.cs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs b/src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs index 2774dfa0f..51e2d1b26 100644 --- a/src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs +++ b/src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs @@ -36,7 +36,7 @@ public sealed class StartEditorServicesCommand : PSCmdlet public StartEditorServicesCommand() { - //Sets the distribution channel to "PSES" so starts can be distinguished in PS7+ telemetry + // Sets the distribution channel to "PSES" so starts can be distinguished in PS7+ telemetry Environment.SetEnvironmentVariable("POWERSHELL_DISTRIBUTION_CHANNEL", "PSES"); _disposableResources = new List(); _loggerUnsubscribers = new List(); diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs index 14bd5389e..eac0d664a 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs @@ -112,7 +112,7 @@ internal async Task LaunchScriptAsync(string scriptToLaunch) { // For a saved file we just execute its path (after escaping it). command = PSCommandHelpers.BuildDotSourceCommandWithArguments( - string.Concat('"', scriptToLaunch, '"'), _debugStateService?.Arguments); + string.Concat("'", scriptToLaunch, "'"), _debugStateService?.Arguments); } else // It's a URI to an untitled script, or a raw script. { diff --git a/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs b/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs index 553024856..a270c694b 100644 --- a/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs +++ b/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs @@ -190,7 +190,7 @@ public async Task UsesDotSourceOperatorAndQuotesAsync() ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(true); Assert.NotNull(configDoneResponse); Assert.Collection(await GetLog().ConfigureAwait(true), - (i) => Assert.StartsWith(". \"", i)); + (i) => Assert.StartsWith(". '", i)); } [Fact] diff --git a/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs b/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs index 43101db9a..29b5dd7ec 100644 --- a/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs +++ b/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs @@ -583,11 +583,11 @@ public async Task RecordsF5CommandInPowerShellHistory() // Check the PowerShell history Assert.Single(historyResult); - Assert.Equal(". \"" + debugScriptFile.FilePath + "\"", historyResult[0]); + Assert.Equal(". '" + debugScriptFile.FilePath + "'", historyResult[0]); // Check the stubbed PSReadLine history Assert.Single(testReadLine.history); - Assert.Equal(". \"" + debugScriptFile.FilePath + "\"", testReadLine.history[0]); + Assert.Equal(". '" + debugScriptFile.FilePath + "'", testReadLine.history[0]); } [Fact]