дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 11:15:40 +02:00
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
69 рядки
2.4 KiB
TypeScript
69 рядки
2.4 KiB
TypeScript
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";
|
|
|
|
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" },
|
|
{ label: "Navigation Bar", action: "navigate.navigationBar", fallback: "⌥Home" },
|
|
{ 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}>
|
|
{(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 (
|
|
<div key={h.label} className={styles.hint}>
|
|
<dt>
|
|
{runnable ? (
|
|
<button type="button" className={styles.hintButton} onClick={() => void executeAction(h.action!)}>
|
|
<T>{h.label}</T>
|
|
</button>
|
|
) : (
|
|
<T>{h.label}</T>
|
|
)}
|
|
</dt>
|
|
{keys && <dd className={styles.keys}>{keys}</dd>}
|
|
</div>
|
|
);
|
|
})}
|
|
</dl>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export function EditorArea() {
|
|
const Provided = useWorkbenchSlots((s) => s.editorArea);
|
|
return (
|
|
<div className={styles.area} data-editor-area="" tabIndex={-1}>
|
|
{Provided ? (
|
|
<ErrorBoundary name="editor area" fallback={<EmptyEditor />}>
|
|
<Slot component={Provided} />
|
|
</ErrorBoundary>
|
|
) : (
|
|
<EmptyEditor />
|
|
)}
|
|
</div>
|
|
);
|
|
}
|