feat(workbench): Open files from Finder in the single-file window (#152)

On macOS, OpenIDEA is now listed under Finder's Open With for text and source files and for folders. It never becomes the default app for any of them: all document types are declared with rank Alternate, and only in tauri.macos.conf.json, so Windows and Linux installers register nothing.

Files opened from Finder, the Dock or a second instance share one routing path (plan_open). A file inside a local project that is already open, or still opening, goes to that project's window, choosing the deepest root when projects are nested. Any other file goes to the existing single-file window, or to a new one. A folder focuses the window that already has it open, otherwise it opens as a project. Paths that arrive before setup are queued and opened with the first launch.

The single-file window now closes with its last tab, restores its files the next time it opens, and only offers Open File and drop hints when empty. Also fixes a regression: reopening projects on startup no longer replaces a file opened at cold start.

Refs #128
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-10-28 23:56:23 +08:00
1 джерело 2d7726cf53
коміт 1d383e608c
12 files changed
+581 -42

No files matched your search

+12 -2
Переглянути файл
@@ -1,11 +1,14 @@
import { executeAction, useActions } from "@/platform/actions";
import { shortcutLabel } from "@/platform/keymap";
import { useProject } from "@/platform/project";
import { T } from "@/ui";
import { useWorkbenchSlots } from "./contributions";
import { ErrorBoundary, Slot } from "./ErrorBoundary";
import styles from "./EditorArea.module.css";
const HINTS: Array<{ label: string; action?: string; fallback?: string }> = [
type Hint = { label: string; action?: string; fallback?: string };
const HINTS: Hint[] = [
{ label: "Search Everywhere", action: "navigate.searchEverywhere", fallback: "Double ⇧" },
{ label: "Go to File", action: "navigate.gotoFile" },
{ label: "Recent Files", action: "navigate.recentFiles" },
@@ -13,13 +16,20 @@ const HINTS: Array<{ label: string; action?: string; fallback?: string }> = [
{ label: "Drop files here to open them" },
];
/** LightEdit has no project to navigate: only opening files works there. */
const LIGHT_EDIT_HINTS: Hint[] = [
{ label: "Open File", action: "file.openFile" },
{ label: "Drop files here to open them" },
];
/** IDEA's empty editor: a few navigation hints with their shortcuts. */
export function EmptyEditor() {
const actions = useActions((s) => s.actions);
const lightEdit = useProject((s) => s.lightEdit);
return (
<div className={styles.empty}>
<dl className={styles.hints}>
{HINTS.map((h) => {
{(lightEdit ? LIGHT_EDIT_HINTS : HINTS).map((h) => {
const keys = h.action ? (shortcutLabel(h.action) ?? h.fallback) : undefined;
const runnable = !!h.action && actions.has(h.action);
return (
+16
Переглянути файл
@@ -5,6 +5,7 @@ import { evaluateWhen } from "@/platform/context";
import { useProject } from "@/platform/project";
import { activateWorkbench } from "./activate";
import { registerStatusItem, registerTitleItem, registerToolWindow } from "./contributions";
import { EmptyEditor } from "./EditorArea";
import { chooseProjectWindow } from "./projectWindow";
import { Workbench } from "./Workbench";
@@ -51,6 +52,21 @@ describe("LightEdit window", () => {
expect(screen.queryByText("Welcome to OpenIDEA")).toBeNull();
});
it("hints only at opening files in an empty editor", () => {
render(<EmptyEditor />);
expect(screen.getByText("Open File")).toBeInTheDocument();
expect(screen.getByText("Drop files here to open them")).toBeInTheDocument();
for (const project of ["Search Everywhere", "Go to File", "Recent Files", "Navigation Bar"])
expect(screen.queryByText(project)).toBeNull();
});
it("keeps the navigation hints in a project window", () => {
useProject.setState({ lightEdit: false });
render(<EmptyEditor />);
expect(screen.getByText("Go to File")).toBeInTheDocument();
expect(screen.queryByText("Open File")).toBeNull();
});
it("sets the context keys that keep project actions off", () => {
const dispose = activateWorkbench();
expect(evaluateWhen("lightEdit")).toBe(true);