diff --git a/frontend/src/components/Editor.jsx b/frontend/src/components/Editor.jsx index 97e1cfb..82fee85 100644 --- a/frontend/src/components/Editor.jsx +++ b/frontend/src/components/Editor.jsx @@ -153,11 +153,6 @@ const Editor = forwardRef(function Editor( }, [editor, content]) // ── Lint check ─────────────────────────────────────────────────────────── - // Keep ref in sync so the onUpdate closure (which never re-captures) always - // calls the latest version of runLint. - useEffect(() => { runLintRef.current = runLint }, [runLint]) - useEffect(() => () => clearTimeout(lintDebounce.current), []) - const runLint = useCallback(async () => { if (!editor || lintStatusRef.current === 'checking') return lintStatusRef.current = 'checking' @@ -208,6 +203,11 @@ const Editor = forwardRef(function Editor( } }, [editor]) + // Keep ref in sync so the stale onUpdate closure always calls the latest runLint + useEffect(() => { runLintRef.current = runLint }, [runLint]) + // Clean up the debounce timer on unmount + useEffect(() => () => clearTimeout(lintDebounce.current), []) + // ── Popover on clicking a lint mark ────────────────────────────────────── function handleEditorClick(e) { if (!editor) return