Procházet zdrojové kódy

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

Chris Estreich před 9 měsíci
rodič
revize
4ce2664fc4

+ 1 - 0
src/integrations/terminal/Terminal.ts

@@ -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
 

+ 14 - 1
src/integrations/terminal/TerminalProcess.ts

@@ -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

+ 5 - 0
src/integrations/terminal/__tests__/TerminalProcess.test.ts

@@ -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)

+ 5 - 0
src/integrations/terminal/__tests__/TerminalProcessExec.test.ts

@@ -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) => {