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]>
Цей коміт міститься в:
Bin authored and GitHub committed 2026-11-30 17:42:57 +08:00
1 джерело a441b2a906
коміт 0104ed63c1
2 files changed
+25

No files matched your search

+23
Переглянути файл
@@ -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."));
+2
Переглянути файл
@@ -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);