Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/integrations/terminal/ExecaTerminalProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import process from "process"
import type { RooTerminal } from "./types"
import { BaseTerminal } from "./BaseTerminal"
import { BaseTerminalProcess } from "./BaseTerminalProcess"
import { getShell } from "../../utils/shell"

export class ExecaTerminalProcess extends BaseTerminalProcess {
private terminalRef: WeakRef<RooTerminal>
Expand Down Expand Up @@ -40,7 +41,7 @@ export class ExecaTerminalProcess extends BaseTerminalProcess {
this.isHot = true

this.subprocess = execa({
shell: BaseTerminal.getExecaShellPath() || true,
shell: BaseTerminal.getExecaShellPath() || getShell(),
cwd: this.terminal.getCurrentWorkingDirectory(),
all: true,
// Ignore stdin to ensure non-interactive mode and prevent hanging
Expand Down
4 changes: 2 additions & 2 deletions src/integrations/terminal/TerminalProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>("defaultProfile.windows")

const isPowerShell =
process.platform === "win32" &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ vitest.mock("ps-tree", () => ({
default: vitest.fn((_: number, cb: any) => cb(null, [])),
}))

vitest.mock("../../../utils/shell", () => ({
getShell: vitest.fn(() => "/mocked/default/shell"),
}))

import { execa } from "execa"
import { ExecaTerminalProcess } from "../ExecaTerminalProcess"
import { BaseTerminal } from "../BaseTerminal"
Expand Down Expand Up @@ -63,7 +67,7 @@ describe("ExecaTerminalProcess", () => {
const execaMock = vitest.mocked(execa)
expect(execaMock).toHaveBeenCalledWith(
expect.objectContaining({
shell: true,
shell: "/mocked/default/shell",
cwd: "/test/cwd",
all: true,
env: expect.objectContaining({
Expand Down Expand Up @@ -105,13 +109,13 @@ describe("ExecaTerminalProcess", () => {
)
})

it("should fall back to shell=true when execaShellPath is undefined", async () => {
it("should fall back to getShell() when execaShellPath is undefined", async () => {
BaseTerminal.setExecaShellPath(undefined)
await terminalProcess.run("echo test")
const execaMock = vitest.mocked(execa)
expect(execaMock).toHaveBeenCalledWith(
expect.objectContaining({
shell: true,
shell: "/mocked/default/shell",
}),
)
})
Expand Down
4 changes: 2 additions & 2 deletions src/utils/__tests__/shell.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ 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, assume modern PowerShell 7 (pwsh.exe) as the default
return SHELL_PATHS.POWERSHELL_7
}

// If there's a specific path, return that immediately
Expand Down
Loading