feat(workbench): Hide Side Tool Windows action (#5744)

Adds Window › Active Tool Window › Hide Side Tool Windows: hides every tool window on the active (else last active) window's side, un-maximizing that side and moving focus to the editor if it was in one of them. Available from Find Action and the native menu, with no default shortcut. IDEA keymap import and IdeaVim :action also map HideSideWindows and the existing Active Tool Window actions (HideActiveWindow, MaximizeToolWindow, JumpToLastWindow, ResizeToolWindow*).

Closes #5743

Co-authored-by: mansur-akhmadi <[email protected]>
Цей коміт міститься в:
Mansur Akhmadiтаmansur-akhmadi authored and GitHub committed 2026-11-25 10:58:31 +08:00
1 джерело 26f83240a7
коміт b9a0c66ca6
29 files changed
+149 -1

No files matched your search

+2
Переглянути файл
@@ -825,6 +825,7 @@ pub fn spec(os: Os) -> Vec<Entry> {
"Active Tool Window",
vec![
act("toolwindow.hideActive", "Hide Active Tool Window"),
act("toolwindow.hideSide", "Hide Side Tool Windows"),
act("toolwindow.maximize", "Maximize Tool Window"),
act("toolwindow.closeContent", "Close Active Tab"),
sub(
@@ -2392,6 +2393,7 @@ mod tests {
&& *id != "toolwindow.hideAll"
&& ![
"toolwindow.hideActive",
"toolwindow.hideSide",
"toolwindow.maximize",
"toolwindow.closeContent",
"toolwindow.jumpToLast",
+8
Переглянути файл
@@ -114,6 +114,14 @@ export const IDEA_ACTIONS: Readonly<Record<string, string>> = {
EditorGutterToggleGlobalStickyLines: "editor.toggleStickyLines",
ActivateProjectToolWindow: "toolwindow.project",
HideAllWindows: "toolwindow.hideAll",
HideActiveWindow: "toolwindow.hideActive",
HideSideWindows: "toolwindow.hideSide",
MaximizeToolWindow: "toolwindow.maximize",
JumpToLastWindow: "toolwindow.jumpToLast",
ResizeToolWindowLeft: "toolwindow.resizeLeft",
ResizeToolWindowRight: "toolwindow.resizeRight",
ResizeToolWindowUp: "toolwindow.resizeUp",
ResizeToolWindowDown: "toolwindow.resizeDown",
"Vcs.QuickListPopupAction": "vcs.operations",
CheckinProject: "vcs.commit",
"Vcs.Push": "vcs.push",
+17
Переглянути файл
@@ -110,6 +110,23 @@ describe("IntelliJ IDEA keymap import", () => {
expect(k.unknownActions).toEqual([]);
});
it("maps the Active Tool Window actions", () => {
const k = parseIdeaKeymap(
`<keymap name="M" parent="$default"><action id="HideSideWindows"><keyboard-shortcut first-keystroke="control alt shift F12"/></action><action id="HideActiveWindow"><keyboard-shortcut first-keystroke="alt ESCAPE"/></action><action id="MaximizeToolWindow"><keyboard-shortcut first-keystroke="control alt M"/></action><action id="JumpToLastWindow"><keyboard-shortcut first-keystroke="alt F12"/></action><action id="ResizeToolWindowLeft"><keyboard-shortcut first-keystroke="control alt LEFT"/></action><action id="ResizeToolWindowRight"><keyboard-shortcut first-keystroke="control alt RIGHT"/></action><action id="ResizeToolWindowUp"><keyboard-shortcut first-keystroke="control alt UP"/></action><action id="ResizeToolWindowDown"><keyboard-shortcut first-keystroke="control alt DOWN"/></action></keymap>`,
);
expect(k.overrides).toMatchObject({
"toolwindow.hideSide": [normalizeBinding("Ctrl+Alt+Shift+F12")],
"toolwindow.hideActive": [normalizeBinding("Alt+Escape")],
"toolwindow.maximize": [normalizeBinding("Ctrl+Alt+M")],
"toolwindow.jumpToLast": [normalizeBinding("Alt+F12")],
"toolwindow.resizeLeft": [normalizeBinding("Ctrl+Alt+Left")],
"toolwindow.resizeRight": [normalizeBinding("Ctrl+Alt+Right")],
"toolwindow.resizeUp": [normalizeBinding("Ctrl+Alt+Up")],
"toolwindow.resizeDown": [normalizeBinding("Ctrl+Alt+Down")],
});
expect(k.unknownActions).toEqual([]);
});
it("rejects other XML", () => {
expect(() => parseIdeaKeymap("<scheme name='x'/>")).toThrow(/keymap/);
});
+1
Переглянути файл
@@ -666,6 +666,7 @@ export const FORWARDABLE_ACTIONS: ReadonlySet<string> = new Set([
"toolwindow.debug",
"toolwindow.hideActive",
"toolwindow.hideAll",
"toolwindow.hideSide",
"toolwindow.jumpToLast",
"toolwindow.focusEditor",
"toolwindow.maximize",
+1
Переглянути файл
@@ -268,6 +268,7 @@ export const intellijMacos: Record<string, string[]> = {
"layout.restoreDefault": [],
"toolwindow.jumpToLast": ["F12"],
"toolwindow.hideActive": ["Shift+Escape"],
"toolwindow.hideSide": [],
"toolwindow.focusEditor": ["Escape"],
// View › Appearance › Enter / Exit Distraction Free Mode: unbound, as in IDEA
// (ToggleDistractionFreeMode has no default). ⌃⌘D is macOS's system-wide
+1
Переглянути файл
@@ -265,6 +265,7 @@ export const intellijWindows: Record<string, string[]> = {
"layout.restoreDefault": [],
"toolwindow.jumpToLast": ["F12"],
"toolwindow.hideActive": ["Shift+Escape"],
"toolwindow.hideSide": [],
"toolwindow.focusEditor": ["Escape"],
"editor.toggleZen": [],
"editor.toggleLineNumbers": [],
+1
Переглянути файл
@@ -292,6 +292,7 @@ export const vscodeMacos: Record<string, string[]> = {
"toolwindow.maximize": [],
"toolwindow.jumpToLast": [],
"toolwindow.hideActive": ["Meta+J"],
"toolwindow.hideSide": [],
"toolwindow.focusEditor": ["Escape"],
// Build (Terminal › Run Build Task)
+1
Переглянути файл
@@ -481,6 +481,7 @@
"menu.layout.delete": "Delete Layout…",
"menu.activeToolWindow": "Active Tool Window",
"menu.toolwindow.hideActive": "Hide Active Tool Window",
"menu.toolwindow.hideSide": "Hide Side Tool Windows",
"menu.toolwindow.maximize": "Maximize Tool Window",
"menu.toolwindow.closeContent": "Close Active Tab",
"menu.toolwindow.jumpToLast": "Jump to Last Tool Window",
+1
Переглянути файл
@@ -400,6 +400,7 @@
"menu.layout.delete": "Eliminar diseño…",
"menu.activeToolWindow": "Ventana de herramientas activa",
"menu.toolwindow.hideActive": "Ocultar ventana de herramientas activa",
"menu.toolwindow.hideSide": "Ocultar ventanas de herramientas laterales",
"menu.toolwindow.maximize": "Maximizar ventana de herramientas",
"menu.toolwindow.closeContent": "Cerrar pestaña activa",
"menu.toolwindow.jumpToLast": "Ir a la última ventana de herramientas",
+1
Переглянути файл
@@ -398,6 +398,7 @@
"menu.layout.delete": "Supprimer la disposition…",
"menu.activeToolWindow": "Fenêtre d'outil active",
"menu.toolwindow.hideActive": "Masquer la fenêtre d'outil active",
"menu.toolwindow.hideSide": "Masquer les fenêtres d'outils latérales",
"menu.toolwindow.maximize": "Agrandir la fenêtre d'outil",
"menu.toolwindow.closeContent": "Fermer l'onglet actif",
"menu.toolwindow.jumpToLast": "Aller à la dernière fenêtre d'outil",
+1
Переглянути файл
@@ -406,6 +406,7 @@
"menu.layout.delete": "레이아웃 삭제…",
"menu.activeToolWindow": "활성 도구 창",
"menu.toolwindow.hideActive": "활성 도구 창 숨기기",
"menu.toolwindow.hideSide": "측면 도구 창 숨기기",
"menu.toolwindow.maximize": "도구 창 최대화",
"menu.toolwindow.closeContent": "활성 탭 닫기",
"menu.toolwindow.jumpToLast": "마지막 도구 창으로 이동",
+1
Переглянути файл
@@ -400,6 +400,7 @@
"menu.layout.delete": "Usuń układ…",
"menu.activeToolWindow": "Aktywne okno narzędziowe",
"menu.toolwindow.hideActive": "Ukryj aktywne okno narzędziowe",
"menu.toolwindow.hideSide": "Ukryj boczne okna narzędziowe",
"menu.toolwindow.maximize": "Maksymalizuj okno narzędziowe",
"menu.toolwindow.closeContent": "Zamknij aktywną kartę",
"menu.toolwindow.jumpToLast": "Przejdź do ostatniego okna narzędziowego",
+1
Переглянути файл
@@ -397,6 +397,7 @@
"menu.layout.delete": "Excluir layout…",
"menu.activeToolWindow": "Janela de ferramentas ativa",
"menu.toolwindow.hideActive": "Ocultar janela de ferramentas ativa",
"menu.toolwindow.hideSide": "Ocultar janelas de ferramentas laterais",
"menu.toolwindow.maximize": "Maximizar janela de ferramentas",
"menu.toolwindow.closeContent": "Fechar aba ativa",
"menu.toolwindow.jumpToLast": "Ir para a última janela de ferramentas",
+1
Переглянути файл
@@ -480,6 +480,7 @@
"menu.layout.delete": "Удалить макет…",
"menu.activeToolWindow": "Активное окно инструментов",
"menu.toolwindow.hideActive": "Скрыть активное окно инструментов",
"menu.toolwindow.hideSide": "Скрыть боковые окна инструментов",
"menu.toolwindow.maximize": "Развернуть окно инструментов",
"menu.toolwindow.closeContent": "Закрыть активную вкладку",
"menu.toolwindow.jumpToLast": "Перейти к последнему окну инструментов",
+1
Переглянути файл
@@ -979,6 +979,7 @@
"Hide": "Ocultar",
"Hide Active Tool Window": "Ocultar ventana de herramientas activa",
"Hide All Tool Windows": "Ocultar todas las ventanas de herramientas",
"Hide Side Tool Windows": "Ocultar ventanas de herramientas laterales",
"Hide changes": "Ocultar cambios",
"Hide Coverage": "Ocultar cobertura",
"Hide Library Frames": "Ocultar marcos de bibliotecas",
+1
Переглянути файл
@@ -916,6 +916,7 @@
"Hide": "Masquer",
"Hide Active Tool Window": "Masquer la fenêtre d'outil active",
"Hide All Tool Windows": "Masquer toutes les fenêtres d'outils",
"Hide Side Tool Windows": "Masquer les fenêtres d'outils latérales",
"Hide changes": "Masquer les modifications",
"Hide Coverage": "Masquer la couverture",
"Hide Library Frames": "Masquer les cadres de bibliothèque",
+1
Переглянути файл
@@ -1015,6 +1015,7 @@
"Hide": "숨기기",
"Hide Active Tool Window": "활성 도구 창 숨기기",
"Hide All Tool Windows": "모든 도구 창 숨기기",
"Hide Side Tool Windows": "측면 도구 창 숨기기",
"Hide changes": "변경 사항 숨기기",
"Hide Coverage": "커버리지 숨기기",
"Hide Library Frames": "라이브러리 프레임 숨기기",
+1
Переглянути файл
@@ -971,6 +971,7 @@
"Hide": "Ukryj",
"Hide Active Tool Window": "Ukryj aktywne okno narzędziowe",
"Hide All Tool Windows": "Ukryj wszystkie okna narzędziowe",
"Hide Side Tool Windows": "Ukryj boczne okna narzędziowe",
"Hide changes": "Ukryj zmiany",
"Hide Coverage": "Ukryj pokrycie kodu",
"Hide Library Frames": "Ukryj ramki biblioteczne",
+1
Переглянути файл
@@ -971,6 +971,7 @@
"Hide": "Ocultar",
"Hide Active Tool Window": "Ocultar janela de ferramentas ativa",
"Hide All Tool Windows": "Ocultar todas as janelas de ferramentas",
"Hide Side Tool Windows": "Ocultar janelas de ferramentas laterais",
"Hide changes": "Ocultar alterações",
"Hide Coverage": "Ocultar cobertura",
"Hide Library Frames": "Ocultar frames de biblioteca",
+1
Переглянути файл
@@ -2038,6 +2038,7 @@
"Hide": "Скрыть",
"Hide Active Tool Window": "Скрыть активное окно инструментов",
"Hide All Tool Windows": "Скрыть все окна инструментов",
"Hide Side Tool Windows": "Скрыть боковые окна инструментов",
"Hide changes": "Скрыть изменения",
"Resize changes": "Изменить размер изменений",
"Hide Coverage": "Скрыть покрытие",
+1
Переглянути файл
@@ -3768,6 +3768,7 @@
"Hide": "Gizle",
"Hide Active Tool Window": "Etkin Araç Penceresini Gizle",
"Hide All Tool Windows": "Tüm Araç Pencerelerini Gizle",
"Hide Side Tool Windows": "Yan Araç Pencerelerini Gizle",
"Hide changes": "Değişiklikleri gizle",
"Hide Coverage": "Kapsamayı Gizle",
"Hide Library Frames": "Kütüphane Çerçevelerini Gizle",
+1
Переглянути файл
@@ -1650,6 +1650,7 @@
"Hide": "隱藏",
"Hide Active Tool Window": "隱藏活動工具視窗",
"Hide All Tool Windows": "隱藏所有工具視窗",
"Hide Side Tool Windows": "隱藏側邊工具視窗",
"Hide changes": "隱藏更改",
"Resize changes": "調整更改面板寬度",
"Hide Coverage": "隱藏覆蓋率",
+1
Переглянути файл
@@ -2061,6 +2061,7 @@
"Hide": "隐藏",
"Hide Active Tool Window": "隐藏活动工具窗口",
"Hide All Tool Windows": "隐藏所有工具窗口",
"Hide Side Tool Windows": "隐藏侧边工具窗口",
"Hide changes": "隐藏更改",
"Resize changes": "调整更改面板宽度",
"Hide Coverage": "隐藏覆盖率",
+1
Переглянути файл
@@ -475,6 +475,7 @@
"menu.layout.delete": "Düzeni Sil…",
"menu.activeToolWindow": "Etkin Araç Penceresi",
"menu.toolwindow.hideActive": "Etkin Araç Penceresini Gizle",
"menu.toolwindow.hideSide": "Yan Araç Pencerelerini Gizle",
"menu.toolwindow.maximize": "Araç Penceresini Ekranı Kaplayacak Şekilde Büyüt",
"menu.toolwindow.closeContent": "Etkin Sekmeyi Kapat",
"menu.toolwindow.jumpToLast": "Son Araç Penceresine Git",
+1
Переглянути файл
@@ -475,6 +475,7 @@
"menu.layout.delete": "刪除佈局…",
"menu.activeToolWindow": "活動工具視窗",
"menu.toolwindow.hideActive": "隱藏活動工具視窗",
"menu.toolwindow.hideSide": "隱藏側邊工具視窗",
"menu.toolwindow.maximize": "最大化工具視窗",
"menu.toolwindow.closeContent": "關閉活動分頁",
"menu.toolwindow.jumpToLast": "跳轉到上一個工具視窗",
+1
Переглянути файл
@@ -481,6 +481,7 @@
"menu.layout.delete": "删除布局…",
"menu.activeToolWindow": "活动工具窗口",
"menu.toolwindow.hideActive": "隐藏活动工具窗口",
"menu.toolwindow.hideSide": "隐藏侧边工具窗口",
"menu.toolwindow.maximize": "最大化工具窗口",
"menu.toolwindow.closeContent": "关闭活动标签页",
"menu.toolwindow.jumpToLast": "跳转到上一个工具窗口",
+10
Переглянути файл
@@ -23,6 +23,7 @@ import {
activateToolWindow,
hideActiveToolWindow,
hideAllToolWindows,
hideSideToolWindows,
hideToolWindow,
jumpToLastToolWindow,
lastUsedToolWindow,
@@ -247,6 +248,15 @@ export function installToolWindowActions(): () => void {
when: "projectOpen && !popupOpen",
run: hideActiveToolWindow,
},
{
// IDEA's HideSideWindows: every window on the active window's side.
id: "toolwindow.hideSide",
title: "Hide Side Tool Windows",
category: "Window",
keywords: ["tool window"],
when: "projectOpen && !popupOpen",
run: hideSideToolWindows,
},
{
// Close Content, as IDEA (⌘W / Ctrl+F4 in a tool window): the selected closable tab, else the window.
id: "toolwindow.closeContent",
+70 -1
Переглянути файл
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { getContext } from "@/platform/context";
import { getContext, setContext } from "@/platform/context";
import { useProject } from "@/platform/project";
import { actionToggled, executeAction, getAction } from "@/platform/actions";
import { registerToolWindow } from "../contributions";
@@ -14,6 +14,7 @@ import {
restoreSidesAfterNarrowWindow,
hideActiveToolWindow,
hideAllToolWindows,
hideSideToolWindows,
hideToolWindow,
hasStripeButton,
removeFromStripe,
@@ -108,6 +109,58 @@ describe("tool window semantics", () => {
expect(isToolWindowVisible("project")).toBe(true);
});
it("hide side hides every window docked on the active window's side", () => {
moveToolWindow("structure", "left-split");
showToolWindow("structure");
showToolWindow("terminal");
setFocusedToolWindow("structure");
hideSideToolWindows();
expect(useToolWindowLayout.getState().visible).toMatchObject({
left: null,
"left-split": null,
bottom: "terminal",
});
expect(useToolWindowLayout.getState().lastActive).toBeNull();
// Again with the side empty and nothing active: nothing else is hidden.
hideSideToolWindows();
expect(isToolWindowVisible("terminal")).toBe(true);
});
it("hide side falls back to the last active window, and does nothing when it is hidden", () => {
showToolWindow("terminal");
showToolWindow("project");
setFocusedToolWindow(null);
expect(useToolWindowLayout.getState().lastActive).toBe("project");
hideSideToolWindows();
expect(isToolWindowVisible("project")).toBe(false);
expect(isToolWindowVisible("terminal")).toBe(true);
showToolWindow("structure");
hideToolWindow("structure");
useToolWindowLayout.setState({ lastActive: "structure" });
hideSideToolWindows();
expect(isToolWindowVisible("terminal")).toBe(true);
});
it("hide side restores a maximized side and leaves another maximized side alone", () => {
showToolWindow("terminal");
toggleMaximizeToolWindow("terminal");
setFocusedToolWindow("terminal");
hideSideToolWindows();
expect(useToolWindowLayout.getState()).toMatchObject({
maximized: null,
visible: { bottom: null, left: "project" },
});
showToolWindow("terminal");
toggleMaximizeToolWindow("terminal");
// The left side is covered by the maximized bottom: its window is not the one shown.
useToolWindowLayout.setState({ focused: null, lastActive: "project" });
hideSideToolWindows();
expect(useToolWindowLayout.getState()).toMatchObject({
maximized: "bottom",
visible: { bottom: "terminal", left: "project" },
});
});
it("restores the maximized side through the shared Hide All toggle", () => {
showToolWindow("terminal");
toggleMaximizeToolWindow("terminal");
@@ -244,6 +297,22 @@ describe("tool window persistence", () => {
});
describe("tool window actions", () => {
it("runs Hide Side Tool Windows on the active window", async () => {
const dispose = installToolWindowActions();
try {
setContext("projectOpen", true);
showToolWindow("terminal");
setFocusedToolWindow("project");
expect(getAction("toolwindow.hideSide")?.title).toBe("Hide Side Tool Windows");
await executeAction("toolwindow.hideSide");
expect(isToolWindowVisible("project")).toBe(false);
expect(isToolWindowVisible("terminal")).toBe(true);
} finally {
setContext("projectOpen", false);
dispose();
}
});
it("titles Hide All Tool Windows 'Restore Tool Windows' while it would restore them", async () => {
const dispose = installToolWindowActions();
try {
+19
Переглянути файл
@@ -709,6 +709,25 @@ export function hideActiveToolWindow() {
if (id) hideToolWindow(id);
}
/**
* Hide Side Tool Windows (IDEA's HideSideWindows): hides both areas of the side the active
* (else last active) window is docked on. Nothing when that window isn't shown.
*/
export function hideSideToolWindows() {
const s = useToolWindowLayout.getState();
const id = s.focused ?? s.lastActive;
const anchor = id && isToolWindowVisible(id) ? anchorOf(id) : undefined;
if (!anchor) return;
const side = windowsOn(anchor, s.visible);
const hadFocus = side.some((w) => s.focused === w || isFocusWithinToolWindow(w));
update({
visible: { ...s.visible, [anchor]: null, [`${anchor}-split`]: null },
maximized: s.maximized === anchor ? null : s.maximized,
lastActive: s.lastActive && side.includes(s.lastActive) ? null : s.lastActive,
});
if (hadFocus) focusEditor();
}
export function setToolWindowSize(anchor: ToolWindowAnchor, px: number) {
const s = useToolWindowLayout.getState();
const v = Math.round(px);