From fa24ef5fc83a2c533a521a61f0c8319924338d9e Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Tue, 17 May 2022 13:08:42 -0700 Subject: [PATCH] Wrap untitled script with newlines --- .../DebugAdapter/Handlers/ConfigurationDoneHandler.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs index d22dde4ee..957b435fa 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs @@ -135,9 +135,10 @@ private async Task LaunchScriptAsync(string scriptToLaunch) else { // Without the new APIs we can only execute the untitled script's contents. - // Command breakpoints and `Wait-Debugger` will work. + // Command breakpoints and `Wait-Debugger` will work. We must wrap the script + // with newlines so that any included comments don't break the command. command = PSCommandHelpers.BuildDotSourceCommandWithArguments( - string.Concat("{ ", untitledScript.Contents, " }"), _debugStateService.Arguments); + string.Concat("{\n", untitledScript.Contents, "\n}"), _debugStateService.Arguments); } } else