дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-01 06:42:54 +02:00
fix(project-tree): open external files on double-click only (#6993)
Single-click in the project tree opened files associated with an external application. Those now open on double-click only. Co-authored-by: ffgenius <[email protected]>
Цей коміт міститься в:
2 files changed
+25
No files matched your search
@@ -7,6 +7,7 @@ import { applyKeymapSettings, installKeyboardDispatcher, useKeymap } from "@/pla
|
||||
import { usePlatform } from "@/platform/platformInfo";
|
||||
import {
|
||||
provideEditorService,
|
||||
registerExternalFileOpenHandler,
|
||||
registerProjectViewRoot,
|
||||
setFileDecorations,
|
||||
type EditorService,
|
||||
@@ -493,6 +494,28 @@ describe("ProjectView", () => {
|
||||
expect(openFile).toHaveBeenLastCalledWith("/w/acme/README.md", { preview: undefined, focus: true });
|
||||
});
|
||||
|
||||
it("selects a file opened externally on single click and opens it on double click", async () => {
|
||||
fs = new MemoryFs({ "/w/acme/notes.docx": "x" }, ROOT);
|
||||
setProjectFsForTests(fs, ROOT);
|
||||
initProjectTree(ROOT, "acme");
|
||||
const disposeExternal = registerExternalFileOpenHandler({
|
||||
id: "test.external",
|
||||
matches: (path) => path.endsWith(".docx"),
|
||||
open: vi.fn(async () => true),
|
||||
});
|
||||
try {
|
||||
const { row, rows } = setup();
|
||||
await waitFor(() => expect(rows()).toContain("notes.docx"));
|
||||
const content = row("notes.docx").querySelector("[data-project-path]")!;
|
||||
fireEvent.click(content, { detail: 1 });
|
||||
expect(openFile).not.toHaveBeenCalled();
|
||||
fireEvent.doubleClick(row("notes.docx"));
|
||||
expect(openFile).toHaveBeenLastCalledWith("/w/acme/notes.docx", { preview: undefined, focus: true });
|
||||
} finally {
|
||||
disposeExternal();
|
||||
}
|
||||
});
|
||||
|
||||
it("opens a selected file in a read-only Quick Preview with Space without creating an editor tab", async () => {
|
||||
dispatchViaKeymap();
|
||||
ipc.fsReadText.mockResolvedValue(ok("# Preview\n\nRead without opening a tab."));
|
||||
|
||||
@@ -34,6 +34,7 @@ import { macStroke, strokeOf } from "@/platform/keymap";
|
||||
import {
|
||||
OWNS_FILE_DROP,
|
||||
getFileDecoration,
|
||||
opensExternally,
|
||||
prepareMenuGroups,
|
||||
useFileDecoration,
|
||||
useFileDecorations,
|
||||
@@ -718,6 +719,7 @@ export function ProjectView() {
|
||||
if (o.singleClickExpand) toggleExpanded(node);
|
||||
return;
|
||||
}
|
||||
if (opensExternally(node.path)) return;
|
||||
if (!o.singleClickOpen && !previewTabEnabled()) return;
|
||||
const opts = { preview: o.singleClickOpen ? undefined : true, focus: false };
|
||||
if (node.member) void revealRange(node.path, { start: node.member.selection_range.start }, opts);
|
||||
|
||||
Reference in new issue
Заблокувати користувача