From 6ecc8591329b0e8fcbd0c5d4d53e86a09737b673 Mon Sep 17 00:00:00 2001 From: LucasArona Date: Mon, 9 Sep 2024 22:34:52 +0200 Subject: [PATCH] Add a setting to launch scripts with the Call operator instead of the DotSource operator Add support to switch the ExecuteMode from DotSource to Call --- package.json | 16 +++++++++++++++- src/features/DebugSession.ts | 1 + src/settings.ts | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 325d573c30..38a09f7406 100644 --- a/package.json +++ b/package.json @@ -462,7 +462,7 @@ "name": "PowerShell Launch Script", "type": "PowerShell", "request": "launch", - "script": "^\"enter path or command to execute e.g.: \\${workspaceFolder}/src/foo.ps1 or Invoke-Pester\"", + "script": "^\"Enter path or command to execute, for example, \\${workspaceFolder}/src/foo.ps1 or Invoke-Pester\"", "cwd": "^\"\\${cwd}\"" } }, @@ -909,6 +909,20 @@ "default": false, "markdownDescription": "Creates a temporary PowerShell Extension Terminal for each debugging session. This is useful for debugging PowerShell classes and binary modules." }, + "powershell.debugging.executeMode": { + "type": "string", + "enum": [ + "DotSource", + "Call" + ], + "default": "DotSource", + "markdownEnumDescriptions": [ + "Use the Dot-Source operator `.` to launch the script, for example, `. 'C:\\Data\\MyScript.ps1'`", + "Use the Call operator `&` to launch the script, for example, `& 'C:\\Data\\MyScript.ps1'`" + ], + "markdownDescription": "Sets the operator used to launch scripts." + + }, "powershell.developer.bundledModulesPath": { "type": "string", "default": "../../PowerShellEditorServices/module", diff --git a/src/features/DebugSession.ts b/src/features/DebugSession.ts index 1788ae7589..748c867849 100644 --- a/src/features/DebugSession.ts +++ b/src/features/DebugSession.ts @@ -290,6 +290,7 @@ export class DebugSessionFeature extends LanguageClientConsumer const settings = getSettings(); config.createTemporaryIntegratedConsole ??= settings.debugging.createTemporaryIntegratedConsole; + config.executeMode ??= settings.debugging.executeMode; if (config.request === "attach") { resolvedConfig = await this.resolveAttachDebugConfiguration(config); } else if (config.request === "launch") { diff --git a/src/settings.ts b/src/settings.ts index 878cac9036..9c2ef38452 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -76,6 +76,11 @@ export enum StartLocation { Panel = "Panel" } +export enum ExecuteMode{ + Call = "Call", + DotSource = "DotSource" +} + export type PowerShellAdditionalExePathSettings = Record; class CodeFormattingSettings extends PartialSettings { @@ -107,6 +112,7 @@ class ScriptAnalysisSettings extends PartialSettings { class DebuggingSettings extends PartialSettings { createTemporaryIntegratedConsole = false; + executeMode = ExecuteMode.DotSource; } class DeveloperSettings extends PartialSettings {