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)
This commit is contained in:
2026-06-14 01:25:05 +05:30
parent 21a00a53a4
commit 2e3f4dda0f
2 changed files with 16 additions and 12 deletions
+4
View File
@@ -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);
@@ -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]);