дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-27 04:56:08 +02:00
With a file open in the editor, VCS Operations › Show Diff (and Show Diff in New Window) opened the file the Project view still had selected, because the target resolver preferred the Project view's retained selection even while the editor owned the context. Show Diff, Show Diff in New Window and Compare with Branch now take the Project view selection only while the tree has focus or owns the context (its lead), the same rule Show History, Add to VCS and Add to .gitignore already use; over the editor the active file wins. The resolver still goes through the commit-window guards, so an amend row or an ignored-only selection there does not fall back to the editor's file. Co-authored-by: aevioni <[email protected]>
49 рядки
2.1 KiB
TypeScript
49 рядки
2.1 KiB
TypeScript
/**
|
|
* Show Diff over the editor through the VCS Operations popup: it targets the editor's file, not
|
|
* the file the Project view still has selected. Git is stubbed at the IPC layer.
|
|
*/
|
|
import { expect, openFromTree, stubDesktop, test } from "./fixtures";
|
|
|
|
const ROOT = "/dev/acme-api";
|
|
const TABLIST = "Editor tabs";
|
|
|
|
test("Show Diff from the VCS Operations popup opens the editor's file, not the Project view selection", async ({
|
|
workbench: page,
|
|
}) => {
|
|
const editor = await openFromTree(page, "build.gradle.kts");
|
|
await stubDesktop(page);
|
|
await page.evaluate(async (root) => {
|
|
const changes = ["build.gradle.kts", "README.md"].map((relPath) => ({
|
|
path: `${root}/${relPath}`,
|
|
relPath,
|
|
staged: null,
|
|
unstaged: "modified",
|
|
renamedFrom: null,
|
|
}));
|
|
const h = window.__ipc.handlers;
|
|
h.vcs_roots = () => [{ root, head: "main", headCommit: "1111111" }];
|
|
h.vcs_branch_info = () => ({ head: "main", headCommit: "1111111", operation: null });
|
|
h.vcs_status = () => changes;
|
|
h.vcs_file_at = () => "";
|
|
h.vcs_compare_scope = () => ({ repositories: [root], skippedPaths: [], singleFile: true });
|
|
const store = "/src/features/vcs/store.ts";
|
|
const { useVcs, refreshNow } = await import(/* @vite-ignore */ store);
|
|
useVcs.setState({ available: true, root, repo: root, branchesLoaded: false, stashesLoaded: false });
|
|
await refreshNow();
|
|
}, ROOT);
|
|
|
|
// The Project view keeps README.md selected while the editor goes back to build.gradle.kts.
|
|
await page.getByRole("treeitem", { name: "README.md", exact: true }).click();
|
|
await page
|
|
.getByRole("tablist", { name: TABLIST })
|
|
.getByRole("tab", { name: "build.gradle.kts", exact: true })
|
|
.click();
|
|
await editor.locator(".cm-content").click();
|
|
|
|
await page.keyboard.press("Control+v");
|
|
await page.getByRole("menuitem", { name: /Show Diff/ }).click();
|
|
|
|
await expect(page.getByRole("tab", { name: "build.gradle.kts (HEAD ↔ Your version)" })).toBeVisible();
|
|
await expect(page.getByRole("tab", { name: "README.md (HEAD ↔ Your version)" })).toHaveCount(0);
|
|
});
|