Файли
openidea/src/workbench/toolwindows/content.ts
T
Mr0Bread c6212293e1 fix(database): close the active result tab, not the Services window, on Close Tab (#3118)
Close Tab (⌘W) with focus in the database results hid the whole Services window: toolwindow.closeContent only closes tabs of strips registered with the window's content-tab registry, which was provided only in tool window header rows. ToolWindowContentTabs registers tab strips rendered in a window's content; the result tabs use it, so Close Tab closes the selected result, and with Output selected the window hides as before.

Co-authored-by: Mr0Bread <[email protected]>
2026-11-13 17:34:42 +08:00

33 рядки
1.3 KiB
TypeScript

import type { TabStripHandle } from "@/ui/Tabs";
/** Content tab strips of each tool window, in its header or content (Run sessions, Find tabs, terminals, query results…). */
const strips = new Map<string, Set<TabStripHandle>>();
const registries = new Map<string, (handle: TabStripHandle) => () => void>();
/** The `TabStripRegistry` value for tool window `id` (stable per id). */
export function contentTabRegistry(id: string): (handle: TabStripHandle) => () => void {
let fn = registries.get(id);
if (!fn) {
fn = (handle) => {
let set = strips.get(id);
if (!set) strips.set(id, (set = new Set()));
set.add(handle);
return () => void set.delete(handle);
};
registries.set(id, fn);
}
return fn;
}
/** Pins or unpins the selected content tab of tool window `id`; false when it has none that can be pinned. */
export function togglePinSelectedContent(id: string): boolean {
for (const strip of strips.get(id) ?? []) if (strip.togglePinSelected()) return true;
return false;
}
/** Closes the selected content tab of tool window `id`; false when it has none that can be closed. */
export function closeSelectedContent(id: string): boolean {
for (const strip of strips.get(id) ?? []) if (strip.closeSelected()) return true;
return false;
}