дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-08 19:02:17 +02:00
fix(search): scope Find in Files to the focused folder (#534)
Find in Files from the keyboard ignored the selected folder and reused the saved scope; only the context menu passed a directory. Focused trees now publish the selected folder, or a file's parent, as an action context, and Find and Replace in Files use it when no explicit directory is given. This covers the Project view, Commit and Changes, Bookmarks and Scratches. Group rows and editor focus keep the previous behaviour. Fixes #526
Цей коміт міститься в:
1 джерело
a553dafa7a
коміт
c5cb217c7c
11 files changed
+352
-9
No files matched your search
@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
||||
import { emitLocalIdeEvent } from "@/platform/ipc";
|
||||
import { getContext } from "@/platform/context";
|
||||
import { provideEditorService, type EditorService } from "@/workbench/contributions";
|
||||
import { provideEditorService, registerProjectViewRoot, type EditorService } from "@/workbench/contributions";
|
||||
import { activate } from "./index";
|
||||
import { setOsClipboardForTests } from "./clipboard";
|
||||
import { MemoryFs, setProjectFsForTests } from "./fs";
|
||||
@@ -164,6 +164,47 @@ describe("ProjectView", () => {
|
||||
expect(getContext().projectViewFocus).toBe(false);
|
||||
});
|
||||
|
||||
it("publishes the selected folder or file parent only while the tree has focus", async () => {
|
||||
const { tree, row, rows } = setup();
|
||||
await waitFor(() => expect(rows()).toContain("README.md"));
|
||||
fireEvent.mouseDown(row("src"));
|
||||
tree.focus();
|
||||
expect(getContext().focusedDirectory).toBe(`${ROOT}/src`);
|
||||
fireEvent.keyDown(tree, { key: "ArrowRight" });
|
||||
await waitFor(() => expect(rows()).toContain("App.kt"));
|
||||
fireEvent.mouseDown(row("App.kt"));
|
||||
expect(getContext().focusedDirectory).toBe(`${ROOT}/src`);
|
||||
fireEvent.mouseDown(row("README.md"));
|
||||
expect(getContext().focusedDirectory).toBe(ROOT);
|
||||
fireEvent.blur(tree);
|
||||
expect(getContext().focusedDirectory).toBeUndefined();
|
||||
});
|
||||
|
||||
it("publishes Scratches paths through the same Project tree", async () => {
|
||||
fs.nodes.set("/scratches", { kind: "dir" });
|
||||
fs.nodes.set("/scratches/note.txt", { kind: "file", size: 0 });
|
||||
const remove = registerProjectViewRoot({
|
||||
id: "scratch-test",
|
||||
path: "/scratches",
|
||||
label: "Scratches",
|
||||
icon: "scratches",
|
||||
scope: "scratches",
|
||||
});
|
||||
try {
|
||||
const { tree, row, rows } = setup();
|
||||
await waitFor(() => expect(rows()).toContain("Scratches"));
|
||||
fireEvent.mouseDown(row("Scratches"));
|
||||
tree.focus();
|
||||
expect(getContext().focusedDirectory).toBe("/scratches");
|
||||
fireEvent.keyDown(tree, { key: "ArrowRight" });
|
||||
await waitFor(() => expect(rows()).toContain("note.txt"));
|
||||
fireEvent.mouseDown(row("note.txt"));
|
||||
expect(getContext().focusedDirectory).toBe("/scratches");
|
||||
} finally {
|
||||
act(() => remove());
|
||||
}
|
||||
});
|
||||
|
||||
it("renames in IDEA's Rename dialog with Shift+F6, validating conflicts, and undoes with ⌘Z", async () => {
|
||||
const { tree, row, rows } = setup();
|
||||
await waitFor(() => expect(rows()).toContain("README.md"));
|
||||
|
||||
@@ -677,6 +677,7 @@ export function ProjectView() {
|
||||
roots={model.roots}
|
||||
getKey={getKey}
|
||||
getLabel={getLabel}
|
||||
getDirectory={(node) => (node.group || node.placeholder ? null : targetFolder(node))}
|
||||
getChildren={getChildren}
|
||||
isExpandable={isExpandable}
|
||||
loadChildren={loadChildren}
|
||||
|
||||
Reference in new issue
Заблокувати користувача