🐛 fix(vscode): URI 开终端复用已有标签组,不再强制劈栏

This commit is contained in:
cruldra committed 2026-09-04 12:21:19 +08:00
1 parent f4b1d80105
commit 0e144bc28f
3 files changed
+62 -4

No files matched your search

+18
View File
@@ -5,3 +5,21 @@
export function terminalEditorColumn(split: boolean): 2 | -1 {
return split ? 2 : -1
}
export interface EditorTabGroupLike {
readonly viewColumn: number
readonly isActive: boolean
readonly tabs: ReadonlyArray<{ readonly isTerminal: boolean }>
}
/** URI / 无看板开终端:复用已有终端所在组,避免无 panel 时强制劈出第 2 栏。 */
export function existingTerminalGroupColumn(groups: readonly EditorTabGroupLike[]): number {
const hasTerminal = (g: EditorTabGroupLike) => g.tabs.some(t => t.isTerminal)
const active = groups.find(g => g.isActive && hasTerminal(g))
if (active)
return active.viewColumn // ① 活动组已有终端 → 加进当前组,不劈栏
const first = groups.find(hasTerminal)
if (first)
return first.viewColumn // ② 终端在别的组 → 跟过去,不新开一栏
return -1 // ③ 一个终端组都没有 → Active(当前组只加标签),绝不默认 2
}