Merge pull request #1585 from KJ7LNW/roo-fix-win32-terminal-dup-command-issue

This commit is contained in:
Chris Estreich 2025-03-12 08:46:24 -07:00 committed by GitHub
commit 4ce2664fc4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 1 deletions

View file

@ -11,6 +11,7 @@ export class Terminal {
private streamClosed: boolean
public process?: TerminalProcess
public taskId?: string
public cmdCounter: number = 0
public completedProcesses: TerminalProcess[] = []
private initialCwd: string

View file

@ -276,7 +276,20 @@ export class TerminalProcess extends EventEmitter<TerminalProcessEvents> {
})
// Execute command
terminal.shellIntegration.executeCommand(command)
const defaultWindowsShellProfile = vscode.workspace
.getConfiguration("terminal.integrated.defaultProfile")
.get("windows")
const isPowerShell =
process.platform === "win32" &&
(defaultWindowsShellProfile === null ||
(defaultWindowsShellProfile as string)?.toLowerCase().includes("powershell"))
if (isPowerShell) {
terminal.shellIntegration.executeCommand(
`${command} ; ${this.terminalInfo.cmdCounter++} > $null; start-sleep -milliseconds 150`,
)
} else {
terminal.shellIntegration.executeCommand(command)
}
this.isHot = true
// Wait for stream to be available

View file

@ -10,6 +10,11 @@ import { TerminalRegistry } from "../TerminalRegistry"
const mockCreateTerminal = jest.fn()
jest.mock("vscode", () => ({
workspace: {
getConfiguration: jest.fn().mockReturnValue({
get: jest.fn().mockReturnValue(null),
}),
},
window: {
createTerminal: (...args: any[]) => {
mockCreateTerminal(...args)

View file

@ -14,6 +14,11 @@ jest.mock("vscode", () => {
}
return {
workspace: {
getConfiguration: jest.fn().mockReturnValue({
get: jest.fn().mockReturnValue(null),
}),
},
window: {
createTerminal: jest.fn(),
onDidStartTerminalShellExecution: jest.fn().mockImplementation((handler) => {