Файли
openidea/src/features/app/index.ts
T
l0ng-ai 1d383e608c 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
2026-10-28 23:56:23 +08:00

58 рядки
2.3 KiB
TypeScript

/**
* Desktop shell integration: native menu bridge, multi-window, window title,
* close / quit guards, About, Keymap Reference, logs, update check and i18n wiring.
*/
import { registerOverlay, registerStatusItem } from "@/workbench/contributions";
import { AboutOverlay } from "./AboutDialog";
import { appActions, checkForUpdatesOnStartup, updateActions } from "./appActions";
import { installCloseGuard } from "./closeGuard";
import { InvalidateCachesOverlay, registerInvalidateCachesActions } from "./InvalidateCaches";
import { buildInfo } from "./host";
import { KeymapReferenceOverlay } from "./KeymapReference";
import { LightEditStatus } from "./LightEditStatus";
import { installLocaleSync, registerLocalizedActions } from "./locale";
import { installMenuBridge } from "./menuBridge";
import { NewProjectOverlay } from "./NewProject";
import { projectActions, registerPowerSaveBanner } from "./projectActions";
import { installWindowTitle } from "./title";
import { installLaunchHandling, installLightEditAutoClose, windowActions } from "./windows";
/** The UI locale of a secondary (Settings) window. */
export const activateLocale = installLocaleSync;
export function activate(): () => void {
const disposers = [
installLocaleSync(),
registerLocalizedActions(() => [...appActions(), ...windowActions()]),
registerOverlay({ id: "app.about", component: AboutOverlay }),
registerOverlay({ id: "app.keymapReference", component: KeymapReferenceOverlay }),
registerOverlay({ id: "app.invalidateCaches", component: InvalidateCachesOverlay }),
registerOverlay({ id: "app.newProject", component: NewProjectOverlay }),
registerStatusItem({
id: "app.lightEdit",
align: "left",
priority: 20,
component: LightEditStatus,
lightEdit: true,
}),
registerLocalizedActions(projectActions),
registerPowerSaveBanner(),
registerInvalidateCachesActions(),
installMenuBridge(),
installWindowTitle(),
installCloseGuard(),
installLaunchHandling(),
installLightEditAutoClose(),
];
let disposed = false;
void buildInfo().then((b) => {
if (!b?.updates || disposed) return;
disposers.push(registerLocalizedActions(updateActions));
void checkForUpdatesOnStartup();
});
return () => {
disposed = true;
disposers.reverse().forEach((d) => d());
};
}