From 3db04f2f0d3325340a616b7a7977fe929a6bd7c1 Mon Sep 17 00:00:00 2001 From: yinxue <2643126914@qq.com> Date: Fri, 5 Dec 2025 11:16:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E6=8E=89=E6=89=93=E5=BC=80?= =?UTF-8?q?=E8=BF=9C=E7=A8=8B=E6=96=87=E4=BB=B6=E5=A4=B9=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/remote-container.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/remote-container.ts b/src/remote-container.ts index 01553ef..f6377a9 100644 --- a/src/remote-container.ts +++ b/src/remote-container.ts @@ -379,13 +379,19 @@ export default class RemoteContainer { } } + // 添加延迟确保 SSH 隧道完全建立 + await new Promise(resolve => setTimeout(resolve, 3000)); + + // 使用 --new-window 而不是 --reuse-window,避免当前窗口被切换 let terminal = vscode.window.activeTerminal || vscode.window.createTerminal(`Ext Terminal`); terminal.show(true); - const command = `code --remote ssh-remote+root@${host}:${port} ${path} --reuse-window`; + const command = `code --remote ssh-remote+root@${host}:${port} ${path} --new-window`; terminal.sendText(command); + vscode.window.showInformationMessage('端口映射已在本地窗口建立,新窗口将打开远程环境'); + } catch (error) { const errorMessage = error instanceof Error ? error.message : '未知错误'; vscode.window.showErrorMessage(`打开远程文件夹失败: ${errorMessage}`);