From 1a2c45cba8548034d117fc61b8753bfeb849afd8 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Thu, 19 Mar 2026 09:33:58 +0000 Subject: [PATCH] fix: Windows terminal fallback defaults to PowerShell 7 instead of legacy PS 5.1 Fixes two bugs causing Windows users with PS7 configured to get legacy PowerShell 5.1, resulting in UTF-8 encoding issues (mojibake): 1. TerminalProcess.ts: Fix incorrect VS Code config API call that always returned null. Changed from getConfiguration("terminal.integrated.defaultProfile") .get("windows") to getConfiguration("terminal.integrated").get("defaultProfile.windows"). 2. shell.ts: Change PowerShell fallback from legacy PS 5.1 to PS 7 when profile name includes "powershell" but has no explicit path or source, since VS Code auto-discovers PS7 profiles without those properties. Closes #11958 --- src/integrations/terminal/TerminalProcess.ts | 4 ++-- src/utils/__tests__/shell.spec.ts | 4 ++-- src/utils/shell.ts | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/integrations/terminal/TerminalProcess.ts b/src/integrations/terminal/TerminalProcess.ts index d202191b958..117ffc469aa 100644 --- a/src/integrations/terminal/TerminalProcess.ts +++ b/src/integrations/terminal/TerminalProcess.ts @@ -97,8 +97,8 @@ export class TerminalProcess extends BaseTerminalProcess { // Execute command const defaultWindowsShellProfile = vscode.workspace - .getConfiguration("terminal.integrated.defaultProfile") - .get("windows") + .getConfiguration("terminal.integrated") + .get("defaultProfile.windows") const isPowerShell = process.platform === "win32" && diff --git a/src/utils/__tests__/shell.spec.ts b/src/utils/__tests__/shell.spec.ts index 8f370e4d7f1..5882fdc0a4f 100644 --- a/src/utils/__tests__/shell.spec.ts +++ b/src/utils/__tests__/shell.spec.ts @@ -139,11 +139,11 @@ describe("Shell Detection Tests", () => { expect(getShell()).toBe("C:\\Program Files\\PowerShell\\7\\pwsh.exe") }) - it("falls back to legacy PowerShell if profile includes 'powershell' but no path/source", () => { + it("falls back to PowerShell 7 if profile includes 'powershell' but no path/source", () => { mockVsCodeConfig("windows", "PowerShell", { PowerShell: {}, }) - expect(getShell()).toBe("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe") + expect(getShell()).toBe("C:\\Program Files\\PowerShell\\7\\pwsh.exe") }) it("uses WSL bash when profile indicates WSL source", () => { diff --git a/src/utils/shell.ts b/src/utils/shell.ts index 45253c31b08..cd718aaad3a 100644 --- a/src/utils/shell.ts +++ b/src/utils/shell.ts @@ -205,8 +205,9 @@ function getWindowsShellFromVSCode(): string | null { // If the profile is sourced from PowerShell, assume the newest return SHELL_PATHS.POWERSHELL_7 } - // Otherwise, assume legacy Windows PowerShell - return SHELL_PATHS.POWERSHELL_LEGACY + // Otherwise, default to PowerShell 7 (modern) since VS Code auto-discovers + // PS7 profiles without setting an explicit path or source property + return SHELL_PATHS.POWERSHELL_7 } // If there's a specific path, return that immediately