дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 09:11:10 +02:00
feat(editor): double-click the empty tab strip to maximize the editor (#6969)
A double click on the empty part of an editor tab strip (not on a tab, a button or trailing content) now maximizes the editor by hiding all tool windows, the same as a double click on a regular tab; doing it again restores them. Tabs gets an onBlankDoubleClick callback that fires only for the strip itself or its scroller. Closes #6968 Co-authored-by: xuejike <[email protected]>
Цей коміт міститься в:
1 джерело
c8dc613485
коміт
182c7c1dbb
5 files changed
+31
-1
No files matched your search
@@ -145,6 +145,8 @@ Tab placement, the tab limit and what happens when it is reached, the preview ta
|
||||
|
||||
With tabs placed left or right, the tab column is as wide as its longest name, up to a limit. Drag the column's inner edge (or focus it and press `←` / `→`) to change the limit; it applies to every editor group and is remembered.
|
||||
|
||||
Double-click a tab, or the empty part of the tab strip, to maximize the editor: all tool windows are hidden, and doing it again brings them back. Double-clicking a preview tab keeps it open as a regular tab instead.
|
||||
|
||||
## Split editors
|
||||
|
||||
| Action | macOS | Windows / Linux |
|
||||
|
||||
@@ -143,6 +143,8 @@ description: "多光标与选区、行编辑、剪贴板历史、代码折叠、
|
||||
|
||||
标签页放在左侧或右侧时,标签页列的宽度随最长的名称变化,但不超过一个上限。拖动该列靠近编辑器的边缘(或聚焦后按 `←` / `→`)可以调整上限;调整对所有编辑器组生效,并会被记住。
|
||||
|
||||
双击标签页或标签页栏的空白处可以最大化编辑器:隐藏所有工具窗口,再双击一次即恢复。双击预览标签页则会把它转为常规标签页。
|
||||
|
||||
## 拆分编辑器
|
||||
|
||||
| 操作 | macOS | Windows / Linux |
|
||||
|
||||
@@ -399,6 +399,8 @@ function PaneView({ paneId }: { paneId: string }) {
|
||||
onCloseOthers={(id) => void ctrl.closeOthers(paneId, id)}
|
||||
onTogglePin={(id) => ctrl.togglePin(paneId, id)}
|
||||
closeOnShiftClick
|
||||
// IDEA: a double click on the strip's empty part maximizes the editor, as on a tab.
|
||||
onBlankDoubleClick={() => void executeAction("toolwindow.hideAll")}
|
||||
onDoubleClick={(id) => {
|
||||
// IDEA: a preview tab becomes a regular one; any other tab maximizes the editor.
|
||||
if (pane.tabs.find((t) => t.id === id)?.preview) ctrl.keepTab(paneId, id);
|
||||
|
||||
@@ -103,6 +103,16 @@ describe("Tabs interactions", () => {
|
||||
expect(onClose).toHaveBeenCalledWith("b");
|
||||
});
|
||||
|
||||
it("double click on the empty strip calls onBlankDoubleClick, not on a tab", () => {
|
||||
const onBlank = vi.fn();
|
||||
const { container } = render(<Tabs items={items} activeId="a" onSelect={() => {}} onBlankDoubleClick={onBlank} />);
|
||||
fireEvent.doubleClick(screen.getByRole("tab", { name: "A" }));
|
||||
expect(onBlank).not.toHaveBeenCalled();
|
||||
fireEvent.doubleClick(screen.getByRole("tablist"));
|
||||
fireEvent.doubleClick(container.firstElementChild!);
|
||||
expect(onBlank).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("Shift+left-click closes an editor tab without selecting it", () => {
|
||||
const onClose = vi.fn();
|
||||
const onSelect = vi.fn();
|
||||
|
||||
+15
-1
@@ -136,6 +136,8 @@ export interface TabsProps {
|
||||
/** Shift+left-click a tab closes it (editor tabs; plain clicks still select). */
|
||||
closeOnShiftClick?: boolean;
|
||||
onDoubleClick?: (id: string) => void;
|
||||
/** Double click on the empty part of the strip (not on a tab or button), e.g. to maximize the editor. */
|
||||
onBlankDoubleClick?: () => void;
|
||||
onContextMenu?: (id: string, e: MouseEvent) => void;
|
||||
/** `editor`: 30px with separators (editor tabs); `compact`: 28px plain (popups, tool window sub-tabs). */
|
||||
variant?: "editor" | "compact";
|
||||
@@ -176,6 +178,7 @@ export function Tabs({
|
||||
onTogglePin,
|
||||
closeOnShiftClick,
|
||||
onDoubleClick,
|
||||
onBlankDoubleClick,
|
||||
onContextMenu,
|
||||
variant = "editor",
|
||||
trailing,
|
||||
@@ -397,7 +400,18 @@ export function Tabs({
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={stripClass} ref={stripRef}>
|
||||
<div
|
||||
className={stripClass}
|
||||
ref={stripRef}
|
||||
onDoubleClick={
|
||||
onBlankDoubleClick
|
||||
? (e) => {
|
||||
// Only the strip's own background counts: tabs, buttons and trailing content handle their own clicks.
|
||||
if (e.target === e.currentTarget || e.target === scrollRef.current) onBlankDoubleClick();
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{vertical && trailing && <div className={styles.trailing}>{trailing}</div>}
|
||||
<div
|
||||
ref={scrollRef}
|
||||
|
||||
Reference in new issue
Заблокувати користувача