From 2e3f4dda0f8ca64d482d8322078c627174102f31 Mon Sep 17 00:00:00 2001 From: Amit Haridas Date: Sun, 14 Jun 2026 01:25:05 +0530 Subject: [PATCH] fix: add missing rendererReady call and fix temporal dead zone crash - App.tsx: call electronAPI.file.rendererReady() on mount so main process opens pendingFile (files passed via CLI or file associations) - FindReplaceBar: move updateMatchCount declaration before executeCommand to fix 'Cannot access d before initialization' crash in minified build (executeCommand referenced updateMatchCount via closure before its const declaration in the same scope) --- src/renderer/App.tsx | 4 ++++ .../components/editor/FindReplaceBar.tsx | 24 +++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 4a676f4..105653e 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -15,6 +15,10 @@ function App() { useAutoUpdateCheck(); const [printOpen, setPrintOpen] = useState(false); + useEffect(() => { + window.electronAPI?.file?.rendererReady?.(); + }, []); + useEffect(() => { const handler = () => setPrintOpen(true); window.addEventListener('mc:print', handler); diff --git a/src/renderer/components/editor/FindReplaceBar.tsx b/src/renderer/components/editor/FindReplaceBar.tsx index 3eee1a6..124d48b 100644 --- a/src/renderer/components/editor/FindReplaceBar.tsx +++ b/src/renderer/components/editor/FindReplaceBar.tsx @@ -25,18 +25,6 @@ export function FindReplaceBar() { const [useRegex, setUseRegex] = useState(false); const [matchInfo, setMatchInfo] = useState<{ current: number; total: number } | null>(null); - const executeCommand = useCallback( - (fn: (view: EditorView) => boolean | void) => { - const view = getActiveView(); - if (!view) return false; - const result = fn(view); - updateMatchCount(); - view.focus(); - return result; - }, - [updateMatchCount] - ); - const updateMatchCount = useCallback(() => { const view = getActiveView(); if (!view) { @@ -77,6 +65,18 @@ export function FindReplaceBar() { } }, []); + const executeCommand = useCallback( + (fn: (view: EditorView) => boolean | void) => { + const view = getActiveView(); + if (!view) return false; + const result = fn(view); + updateMatchCount(); + view.focus(); + return result; + }, + [updateMatchCount] + ); + const handleFindNext = useCallback(() => { executeCommand(findNext); }, [executeCommand]);