дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 09:11:10 +02:00
fix(toolwindows): keep an undocked window opened from a menu on screen (#5946)
An undocked or unpinned tool window shown with focus from a menu or popup hid again at once: the window takes focus a frame later, and in between the closing menu returned focus to the editor, which hides unpinned windows. A window whose focus request has not reached it yet no longer auto-hides; the request counts as served once the window gets focus or is hidden. Git > Show History with an undocked Git window now opens and stays. Closes #5941 Co-authored-by: formiat <[email protected]>
Цей коміт міститься в:
1 джерело
b8b245da5f
коміт
ebeb6476eb
2 files changed
+24
-1
No files matched your search
@@ -693,6 +693,18 @@ describe("view modes", () => {
|
||||
expect(isToolWindowVisible("terminal")).toBe(false);
|
||||
});
|
||||
|
||||
it("an undocked window activated from a menu survives the menu returning focus to the editor", () => {
|
||||
setToolWindowViewMode("terminal", "undock");
|
||||
showToolWindow("terminal", true);
|
||||
// The closing menu restores focus to the editor before the window takes it.
|
||||
setFocusedToolWindow(null, true);
|
||||
expect(isToolWindowVisible("terminal")).toBe(true);
|
||||
|
||||
setFocusedToolWindow("terminal");
|
||||
setFocusedToolWindow(null, true);
|
||||
expect(isToolWindowVisible("terminal")).toBe(false);
|
||||
});
|
||||
|
||||
it("stay when focus goes to a popup or dialog; pinned windows never hide on focus", () => {
|
||||
setToolWindowViewMode("project", "dockUnpinned");
|
||||
showToolWindow("terminal");
|
||||
|
||||
@@ -548,6 +548,13 @@ export function isToolWindowVisible(id: string): boolean {
|
||||
/** Last shown or focused tool window, kept after it is hidden (Jump to Last Tool Window). */
|
||||
let lastUsed: string | null = null;
|
||||
|
||||
/**
|
||||
* `seq` of the last focus request that reached its window or was dropped with it. A window with a
|
||||
* newer request does not hide as unpinned: a menu that ran the action returns focus to the editor
|
||||
* before the window takes it.
|
||||
*/
|
||||
let servedFocusSeq = 0;
|
||||
|
||||
export function lastUsedToolWindow(): string | null {
|
||||
return lastUsed && anchorOf(lastUsed) ? lastUsed : null;
|
||||
}
|
||||
@@ -589,6 +596,7 @@ export function hideToolWindow(id: string) {
|
||||
const slot = slotOfId(id);
|
||||
const s = useToolWindowLayout.getState();
|
||||
if (!slot || s.visible[slot] !== id) return;
|
||||
if (s.focusRequest?.id === id) servedFocusSeq = s.focusRequest.seq;
|
||||
const hadFocus = s.focused === id || isFocusWithinToolWindow(id);
|
||||
const nextVisible = { ...s.visible, [slot]: null };
|
||||
// The side stays maximized while its other area still shows a registered window.
|
||||
@@ -846,6 +854,8 @@ export function restoreMaximizedToolWindow() {
|
||||
*/
|
||||
export function setFocusedToolWindow(id: string | null, editor = false) {
|
||||
const s = useToolWindowLayout.getState();
|
||||
const request = s.focusRequest;
|
||||
if (id && request?.id === id) servedFocusSeq = request.seq;
|
||||
if (s.focused !== id) {
|
||||
if (id) lastUsed = id;
|
||||
useToolWindowLayout.setState({ focused: id, lastActive: id ?? s.lastActive });
|
||||
@@ -855,7 +865,8 @@ export function setFocusedToolWindow(id: string | null, editor = false) {
|
||||
if (!id && !editor) return;
|
||||
for (const slot of SLOTS) {
|
||||
const shown = useToolWindowLayout.getState().visible[slot];
|
||||
if (shown && shown !== id && viewModeOf(shown) !== "dockPinned") hideToolWindow(shown);
|
||||
const pending = request?.id === shown && request.seq !== servedFocusSeq;
|
||||
if (shown && shown !== id && !pending && viewModeOf(shown) !== "dockPinned") hideToolWindow(shown);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Заблокувати користувача