Skip to content

Commit 4ce2664

Browse files
authored
Merge pull request #1585 from KJ7LNW/roo-fix-win32-terminal-dup-command-issue
2 parents c8b3095 + 50b7326 commit 4ce2664

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

src/integrations/terminal/Terminal.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export class Terminal {
1111
private streamClosed: boolean
1212
public process?: TerminalProcess
1313
public taskId?: string
14+
public cmdCounter: number = 0
1415
public completedProcesses: TerminalProcess[] = []
1516
private initialCwd: string
1617

src/integrations/terminal/TerminalProcess.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,20 @@ export class TerminalProcess extends EventEmitter<TerminalProcessEvents> {
276276
})
277277

278278
// Execute command
279-
terminal.shellIntegration.executeCommand(command)
279+
const defaultWindowsShellProfile = vscode.workspace
280+
.getConfiguration("terminal.integrated.defaultProfile")
281+
.get("windows")
282+
const isPowerShell =
283+
process.platform === "win32" &&
284+
(defaultWindowsShellProfile === null ||
285+
(defaultWindowsShellProfile as string)?.toLowerCase().includes("powershell"))
286+
if (isPowerShell) {
287+
terminal.shellIntegration.executeCommand(
288+
`${command} ; ${this.terminalInfo.cmdCounter++} > $null; start-sleep -milliseconds 150`,
289+
)
290+
} else {
291+
terminal.shellIntegration.executeCommand(command)
292+
}
280293
this.isHot = true
281294

282295
// Wait for stream to be available

src/integrations/terminal/__tests__/TerminalProcess.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import { TerminalRegistry } from "../TerminalRegistry"
1010
const mockCreateTerminal = jest.fn()
1111

1212
jest.mock("vscode", () => ({
13+
workspace: {
14+
getConfiguration: jest.fn().mockReturnValue({
15+
get: jest.fn().mockReturnValue(null),
16+
}),
17+
},
1318
window: {
1419
createTerminal: (...args: any[]) => {
1520
mockCreateTerminal(...args)

src/integrations/terminal/__tests__/TerminalProcessExec.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ jest.mock("vscode", () => {
1414
}
1515

1616
return {
17+
workspace: {
18+
getConfiguration: jest.fn().mockReturnValue({
19+
get: jest.fn().mockReturnValue(null),
20+
}),
21+
},
1722
window: {
1823
createTerminal: jest.fn(),
1924
onDidStartTerminalShellExecution: jest.fn().mockImplementation((handler) => {

0 commit comments

Comments
 (0)