feat(editor): Open in New Window uses a lightweight editor window (#4368)

Open in New Window on a project file's tab now opens an editor-only window (editor-<parent>-n) instead of a second project workbench. It shares the parent's documents and language servers; unsaved text, caret and selection move with the tab, and the source tab is removed only after the new window reports ready. Files outside the project keep opening a full window.

Review changes: closing the window settles only its own unsaved files (the project window's guard also asked to terminate running processes); Escape no longer closes it; error messages go through the text catalog; the window has its own stylesheet.

Closes #4117

Co-authored-by: GGVidal <[email protected]>
Цей коміт міститься в:
Gabriel Gondim authored and GitHub committed 2026-11-19 08:36:35 +08:00
1 джерело 7c3b40b1c4
коміт 4e8a392fed
18 files changed
+543 -26

No files matched your search

+11 -6
Переглянути файл
@@ -11,15 +11,20 @@ describe("auxiliaryWindow", () => {
expect(auxiliaryWindow("comparison-project-2-14")).toEqual({ kind: "comparison", parent: "project-2" });
expect(auxiliaryWindow("diff-main-0")).toEqual({ kind: "diff", parent: "main" });
expect(auxiliaryWindow("diff-project-2-14")).toEqual({ kind: "diff", parent: "project-2" });
expect(auxiliaryWindow("editor-main-0")).toEqual({ kind: "editor", parent: "main" });
expect(auxiliaryWindow("editor-project-2-14")).toEqual({ kind: "editor", parent: "project-2" });
expect(auxiliaryWindow("deployment-project-2")).toEqual({ kind: "deployment", parent: "project-2" });
});
it.each(["settings", "comparison", "diff", "deployment"])("grants %s windows permission to close", (kind) => {
expect(capability.windows).toContain(`${kind}-*`);
expect(bridgeCapability.windows).toContain(`${kind}-*`);
expect(capability.permissions).toContain("core:window:allow-close");
expect(capability.permissions).toContain("core:window:allow-destroy");
});
it.each(["settings", "comparison", "diff", "editor", "deployment"])(
"grants %s windows permission to close",
(kind) => {
expect(capability.windows).toContain(`${kind}-*`);
expect(bridgeCapability.windows).toContain(`${kind}-*`);
expect(capability.permissions).toContain("core:window:allow-close");
expect(capability.permissions).toContain("core:window:allow-destroy");
},
);
it("leaves project windows and malformed labels alone", () => {
for (const label of ["", "main", "project-1", "settings-", "comparison-main", "comparison-main-x"]) {
+13 -3
Переглянути файл
@@ -8,15 +8,25 @@ import { getAllWindows, getCurrentWindow } from "@tauri-apps/api/window";
import { TauriEvent } from "@tauri-apps/api/event";
import { isTauri } from "./ipc";
export type AuxKind = "settings" | "comparison" | "diff" | "deployment";
export type AuxKind = "settings" | "comparison" | "diff" | "editor" | "deployment";
/** Kinds with several windows per parent (`<kind>-<parent>-<n>`); the others have one (`<kind>-<parent>`). */
const MULTIPLE: ReadonlySet<AuxKind> = new Set(["comparison", "diff"]);
const KINDS: readonly AuxKind[] = ["settings", "comparison", "diff", "deployment"];
const MULTIPLE: ReadonlySet<AuxKind> = new Set(["comparison", "diff", "editor"]);
const KINDS: readonly AuxKind[] = ["settings", "comparison", "diff", "editor", "deployment"];
/** An auxiliary window reports to its parent whether it closed, and which documents it released. */
export const AUX_CLOSED = "openidea://auxiliary/closed";
/** Lightweight editor window reports that it opened (or failed to open) the moved file. */
export const EDITOR_READY = "openidea://editor/ready";
export interface EditorReadyResult {
label: string;
path: string;
ok: boolean;
error?: string;
}
export interface AuxCloseResult {
label: string;
closed: boolean;
+6 -1
Переглянути файл
@@ -2535,5 +2535,10 @@
"60 FPS": "60 FPS",
"30 FPS": "30 FPS",
"15 FPS": "15 FPS",
"10 FPS": "10 FPS"
"10 FPS": "10 FPS",
"Could not close editor": "Could not close editor",
"Missing editor request": "Missing editor request",
"The editor’s project is no longer open": "The editor’s project is no longer open",
"Timed out opening the editor window": "Timed out opening the editor window",
"Could not open the editor window": "Could not open the editor window"
}
+6 -1
Переглянути файл
@@ -8909,5 +8909,10 @@
"60 FPS": "60 帧/秒",
"30 FPS": "30 帧/秒",
"15 FPS": "15 帧/秒",
"10 FPS": "10 帧/秒"
"10 FPS": "10 帧/秒",
"Could not close editor": "无法关闭编辑器",
"Missing editor request": "缺少编辑器请求",
"The editor’s project is no longer open": "编辑器所属的项目已关闭",
"Timed out opening the editor window": "打开编辑器窗口超时",
"Could not open the editor window": "无法打开编辑器窗口"
}