дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 10:07:11 +02:00
feat(vcs): option to open diffs in a separate window (#4853)
Adds Settings > Version Control > Confirmation > Open diff as editor tab (default on, client-side workflow setting vcs.diffAsEditorTab). When off, diffs opened from the Commit tool window, history, log and Compare show in a separate Diff window; combined multi-file diffs still open as a tab.
Цей коміт міститься в:
1 джерело
3ec631f0c0
коміт
ba6ccaf9b2
9 files changed
+40
-1
No files matched your search
@@ -752,6 +752,12 @@ export const VCS_PAGES: PageSpec[] = [
|
||||
key: "vcs.showDirtyDirectories",
|
||||
label: "Highlight directories that contain modified files in the Project tree",
|
||||
},
|
||||
{
|
||||
kind: "toggle",
|
||||
key: "vcs.diffAsEditorTab",
|
||||
label: "Open diff as editor tab",
|
||||
hint: "When off, diffs you open (changes, history, Compare) show in a separate window.",
|
||||
},
|
||||
{
|
||||
kind: "select",
|
||||
key: "vcs.confirmation.onPatchCreated",
|
||||
|
||||
@@ -8,6 +8,8 @@ import { showChangesDiff, type LogChange } from "../logChanges";
|
||||
|
||||
const front = vi.hoisted(() => ({ diff: vi.fn(), merge: vi.fn() }));
|
||||
vi.mock("../diffDialog", () => ({ openDiffDialog: front.diff, openMergeDiffDialog: front.merge }));
|
||||
const separate = vi.hoisted(() => vi.fn());
|
||||
vi.mock("../DiffWindow", () => ({ showDiffWindow: separate }));
|
||||
|
||||
/** Editor tabs the diffs open in (openDiff → the editor service). */
|
||||
const openInput = vi.fn(async () => undefined);
|
||||
@@ -75,3 +77,15 @@ it("opens a commit's file diff in the preview tab with the non-modal interface",
|
||||
await showChangesDiff([file]);
|
||||
expect(openInput).toHaveBeenLastCalledWith(expect.objectContaining({ kind: "diff" }), { preview: true, focus: true });
|
||||
});
|
||||
|
||||
it("opens diffs in a separate window when Open diff as editor tab is off", async () => {
|
||||
useProject.setState({ settings: { vcs: { diffAsEditorTab: false } } as Settings });
|
||||
await getAction("diff.compareTexts")!.run({ arg: texts, ctx: {} });
|
||||
expect(separate).toHaveBeenCalledWith(expect.objectContaining({ path: "/p/a.ts" }), expect.any(Function));
|
||||
expect(openInput).not.toHaveBeenCalled();
|
||||
// The modal commit interface still shows them in its front window.
|
||||
useProject.setState({ settings: { vcs: { diffAsEditorTab: false, commit: { nonModal: false } } } as Settings });
|
||||
await getAction("diff.compareTexts")!.run({ arg: texts, ctx: {} });
|
||||
expect(front.diff).toHaveBeenCalledTimes(1);
|
||||
expect(separate).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
@@ -209,7 +209,12 @@ export const opensDiffOnActivate = () => {
|
||||
* (`vcs.openDiff`, with review comments) call openDiff directly.
|
||||
*/
|
||||
export async function openVcsDiff(data: DiffData, opts: { preview?: boolean; focus?: boolean } = {}) {
|
||||
if (!vcsDiffInFront()) return openDiff(data, opts);
|
||||
if (!vcsDiffInFront()) {
|
||||
// Settings › Version Control › Confirmation: "Open diff as editor tab" off.
|
||||
if (workflowSettings().vcs.diffAsEditorTab || combinedOf(data)) return openDiff(data, opts);
|
||||
const { showDiffWindow } = await import("./DiffWindow");
|
||||
return showDiffWindow(data, () => void openDiff(data, opts));
|
||||
}
|
||||
const { openDiffDialog } = await import("./diffDialog");
|
||||
openDiffDialog(data);
|
||||
}
|
||||
|
||||
Reference in new issue
Заблокувати користувача