diff --git a/src/components/molecules/Monaco/Monaco.tsx b/src/components/molecules/Monaco/Monaco.tsx index c65ddd099c..531d8ea3cc 100644 --- a/src/components/molecules/Monaco/Monaco.tsx +++ b/src/components/molecules/Monaco/Monaco.tsx @@ -79,6 +79,7 @@ const Monaco = (props: {editorHeight: string}) => { const [isDirty, setDirty] = useState(false); const [hasWarnings, setWarnings] = useState(false); const [isValid, setValid] = useState(true); + const [firstCodeLoadedOnEditor, setFirstCodeLoadedOnEditor] = useState(false); const editorRef = useRef(null); const idsOfDecorationsRef = useRef([]); @@ -286,6 +287,10 @@ const Monaco = (props: {editorHeight: string}) => { useEffect(() => { clearCodeIntel(); applyCodeIntel(); + + if (!firstCodeLoadedOnEditor && code) { + setFirstCodeLoadedOnEditor(true); + } return () => { clearCodeIntel(); }; @@ -329,11 +334,11 @@ const Monaco = (props: {editorHeight: string}) => { }, [selectedResourceId, resourceMap]); useEffect(() => { - if (editor && code) { + if (editor) { editor.revealLineNearTop(1); editor.setSelection(new monaco.Selection(0, 0, 0, 0)); } - }, [editor, code]); + }, [editor, selectedResourceId, firstCodeLoadedOnEditor]); return ( <>