From 694c2307cd8aec681e2fd6347b9e6c0b1a113fb4 Mon Sep 17 00:00:00 2001 From: elrashed Date: Wed, 3 Aug 2022 12:33:18 -0700 Subject: [PATCH 1/9] verify a powershell terminal --- src/cmakeTools.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cmakeTools.ts b/src/cmakeTools.ts index 2f844192a..826057631 100644 --- a/src/cmakeTools.ts +++ b/src/cmakeTools.ts @@ -2220,14 +2220,15 @@ export class CMakeTools implements api.CMakeToolsAPI { } const userConfig = this.workspaceContext.config.debugConfig; - const terminal = await this.createTerminal(executable); + const terminal: vscode.Terminal = await this.createTerminal(executable); let executablePath = shlex.quote(executable.path); if (process.platform === 'win32') { executablePath = executablePath.replace(/\\/g, "/"); - - if (vscode.env.shell.indexOf("PowerShell") > 0) { + if (vscode.env.shell.indexOf("PowerShell") > 0 + || vscode.env.shell.indexOf("pwsh.exe") > 0 + || ((terminal.creationOptions as vscode.TerminalOptions).env![this.launchTerminalPath])?.includes("pwsh.exe")) { executablePath = `.${executablePath}`; } } From 517b2cfb404d67acfbbc4805f418b67e50be9393 Mon Sep 17 00:00:00 2001 From: elrashed Date: Wed, 3 Aug 2022 12:39:59 -0700 Subject: [PATCH 2/9] launchBehavior reuse terminal --- src/cmakeTools.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cmakeTools.ts b/src/cmakeTools.ts index 826057631..178c11d19 100644 --- a/src/cmakeTools.ts +++ b/src/cmakeTools.ts @@ -2226,9 +2226,11 @@ export class CMakeTools implements api.CMakeToolsAPI { if (process.platform === 'win32') { executablePath = executablePath.replace(/\\/g, "/"); + const launchBehavior = this.workspaceContext.config.launchBehavior.toLowerCase(); + const launchTerminalPath = (terminal.creationOptions as vscode.TerminalOptions).env![this.launchTerminalPath]; if (vscode.env.shell.indexOf("PowerShell") > 0 || vscode.env.shell.indexOf("pwsh.exe") > 0 - || ((terminal.creationOptions as vscode.TerminalOptions).env![this.launchTerminalPath])?.includes("pwsh.exe")) { + || (launchBehavior !== "newterminal" && (launchTerminalPath)?.includes("pwsh.exe"))) { executablePath = `.${executablePath}`; } } From 9c0f15a88a3680c0bee11a706a5f9ddb61b9c17f Mon Sep 17 00:00:00 2001 From: elrashed Date: Wed, 3 Aug 2022 12:47:40 -0700 Subject: [PATCH 3/9] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d39dec91..b376f42df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Bug Fixes: - Clear output channel after auto-reconfigure. [#2628](https://github.com/microsoft/vscode-cmake-tools/issues/2628) - Don't delete CMakeCache.txt when switching kits if the buildDirectory also changes. [#2546](https://github.com/microsoft/vscode-cmake-tools/issues/2546) [@david-fong](https://github.com/david-fong) - Add "description" properties to the cmake.revealLog setting. [#2578](https://github.com/microsoft/vscode-cmake-tools/issues/2578) +- Support launching the target in new powershell terminal. [#2621](https://github.com/microsoft/vscode-cmake-tools/issues/2621) - Detect clang-cl.exe compilers that are not bundled with Visual Studio. [#2622](https://github.com/microsoft/vscode-cmake-tools/issues/2622) From cbd1048aa0b7b5de2c6356e686d158958a2a1949 Mon Sep 17 00:00:00 2001 From: elrashed Date: Wed, 3 Aug 2022 12:48:49 -0700 Subject: [PATCH 4/9] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b376f42df..627e10390 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Bug Fixes: - Clear output channel after auto-reconfigure. [#2628](https://github.com/microsoft/vscode-cmake-tools/issues/2628) - Don't delete CMakeCache.txt when switching kits if the buildDirectory also changes. [#2546](https://github.com/microsoft/vscode-cmake-tools/issues/2546) [@david-fong](https://github.com/david-fong) - Add "description" properties to the cmake.revealLog setting. [#2578](https://github.com/microsoft/vscode-cmake-tools/issues/2578) -- Support launching the target in new powershell terminal. [#2621](https://github.com/microsoft/vscode-cmake-tools/issues/2621) +- Support launching the target in new powershell terminal. [#2650](https://github.com/microsoft/vscode-cmake-tools/issues/2650) - Detect clang-cl.exe compilers that are not bundled with Visual Studio. [#2622](https://github.com/microsoft/vscode-cmake-tools/issues/2622) From ebc8cb649f7350bbe1e01d7e3c4a146b211ed623 Mon Sep 17 00:00:00 2001 From: elrashed Date: Wed, 3 Aug 2022 13:08:26 -0700 Subject: [PATCH 5/9] new --- src/cmakeTools.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/cmakeTools.ts b/src/cmakeTools.ts index 23cfbaacb..92739c84d 100644 --- a/src/cmakeTools.ts +++ b/src/cmakeTools.ts @@ -2226,11 +2226,8 @@ export class CMakeTools implements api.CMakeToolsAPI { if (process.platform === 'win32') { executablePath = executablePath.replace(/\\/g, "/"); - const launchBehavior = this.workspaceContext.config.launchBehavior.toLowerCase(); const launchTerminalPath = (terminal.creationOptions as vscode.TerminalOptions).env![this.launchTerminalPath]; - if (vscode.env.shell.indexOf("PowerShell") > 0 - || vscode.env.shell.indexOf("pwsh.exe") > 0 - || (launchBehavior !== "newterminal" && (launchTerminalPath)?.includes("pwsh.exe"))) { + if (launchTerminalPath?.toLocaleLowerCase().includes("pwsh.exe")) { executablePath = `.${executablePath}`; } } From e0d6ae3f95ae6540488e9b3378aa699c9b37ba65 Mon Sep 17 00:00:00 2001 From: elrashed Date: Wed, 3 Aug 2022 13:12:06 -0700 Subject: [PATCH 6/9] changelog --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 627e10390..29579a700 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,8 +12,7 @@ Bug Fixes: - Clear output channel after auto-reconfigure. [#2628](https://github.com/microsoft/vscode-cmake-tools/issues/2628) - Don't delete CMakeCache.txt when switching kits if the buildDirectory also changes. [#2546](https://github.com/microsoft/vscode-cmake-tools/issues/2546) [@david-fong](https://github.com/david-fong) - Add "description" properties to the cmake.revealLog setting. [#2578](https://github.com/microsoft/vscode-cmake-tools/issues/2578) -- Support launching the target in new powershell terminal. [#2650](https://github.com/microsoft/vscode-cmake-tools/issues/2650) - +- Fix issues with launching the target in PowerShell terminal. [#2650](https://github.com/microsoft/vscode-cmake-tools/issues/2650) [#2621](https://github.com/microsoft/vscode-cmake-tools/issues/2621) [#535](https://github.com/microsoft/vscode-cmake-tools/issues/535) - Detect clang-cl.exe compilers that are not bundled with Visual Studio. [#2622](https://github.com/microsoft/vscode-cmake-tools/issues/2622) ## 1.11.26 From 533927dc94a629edc9b4d8d9baa24a5e6d2e07e5 Mon Sep 17 00:00:00 2001 From: elrashed Date: Wed, 3 Aug 2022 13:20:28 -0700 Subject: [PATCH 7/9] update --- src/cmakeTools.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmakeTools.ts b/src/cmakeTools.ts index 92739c84d..bacd5bde9 100644 --- a/src/cmakeTools.ts +++ b/src/cmakeTools.ts @@ -2226,8 +2226,8 @@ export class CMakeTools implements api.CMakeToolsAPI { if (process.platform === 'win32') { executablePath = executablePath.replace(/\\/g, "/"); - const launchTerminalPath = (terminal.creationOptions as vscode.TerminalOptions).env![this.launchTerminalPath]; - if (launchTerminalPath?.toLocaleLowerCase().includes("pwsh.exe")) { + const launchTerminalPath = (terminal.creationOptions as vscode.TerminalOptions).env![this.launchTerminalPath]?.toLocaleLowerCase(); + if (launchTerminalPath?.includes("pwsh.exe") || launchTerminalPath?.includes("powershell")) { executablePath = `.${executablePath}`; } } From 4cbc877d532626e92583733b29692b2366d57325 Mon Sep 17 00:00:00 2001 From: elrashed Date: Thu, 4 Aug 2022 09:41:31 -0700 Subject: [PATCH 8/9] add pwsh for linux and mac --- src/cmakeTools.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cmakeTools.ts b/src/cmakeTools.ts index bacd5bde9..98d133607 100644 --- a/src/cmakeTools.ts +++ b/src/cmakeTools.ts @@ -2223,13 +2223,17 @@ export class CMakeTools implements api.CMakeToolsAPI { const terminal: vscode.Terminal = await this.createTerminal(executable); let executablePath = shlex.quote(executable.path); - + let launchTerminalPath = (terminal.creationOptions as vscode.TerminalOptions).env![this.launchTerminalPath]; if (process.platform === 'win32') { executablePath = executablePath.replace(/\\/g, "/"); - const launchTerminalPath = (terminal.creationOptions as vscode.TerminalOptions).env![this.launchTerminalPath]?.toLocaleLowerCase(); + launchTerminalPath = launchTerminalPath?.toLocaleLowerCase(); if (launchTerminalPath?.includes("pwsh.exe") || launchTerminalPath?.includes("powershell")) { executablePath = `.${executablePath}`; } + } else { + if (launchTerminalPath?.endsWith("pwsh")) { + executablePath = `.${executablePath}`; + } } let launchArgs = ''; From 4c6a880122421493c602b99bc70ddccaf008a2af Mon Sep 17 00:00:00 2001 From: elrashed Date: Thu, 4 Aug 2022 15:38:42 -0700 Subject: [PATCH 9/9] tested on wsl --- src/cmakeTools.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/cmakeTools.ts b/src/cmakeTools.ts index 98d133607..70ff58bb3 100644 --- a/src/cmakeTools.ts +++ b/src/cmakeTools.ts @@ -2223,16 +2223,18 @@ export class CMakeTools implements api.CMakeToolsAPI { const terminal: vscode.Terminal = await this.createTerminal(executable); let executablePath = shlex.quote(executable.path); - let launchTerminalPath = (terminal.creationOptions as vscode.TerminalOptions).env![this.launchTerminalPath]; - if (process.platform === 'win32') { - executablePath = executablePath.replace(/\\/g, "/"); - launchTerminalPath = launchTerminalPath?.toLocaleLowerCase(); - if (launchTerminalPath?.includes("pwsh.exe") || launchTerminalPath?.includes("powershell")) { - executablePath = `.${executablePath}`; - } - } else { - if (launchTerminalPath?.endsWith("pwsh")) { - executablePath = `.${executablePath}`; + if (executablePath.startsWith("\"")) { + let launchTerminalPath = (terminal.creationOptions as vscode.TerminalOptions).env![this.launchTerminalPath]; + if (process.platform === 'win32') { + executablePath = executablePath.replace(/\\/g, "/"); + launchTerminalPath = launchTerminalPath?.toLocaleLowerCase(); + if (launchTerminalPath?.includes("pwsh.exe") || launchTerminalPath?.includes("powershell")) { + executablePath = `.${executablePath}`; + } + } else { + if (launchTerminalPath?.endsWith("pwsh")) { + executablePath = `.${executablePath}`; + } } }