Skip to content

Commit

Permalink
fix: refs not highlighted on first resource view
Browse files Browse the repository at this point in the history
  • Loading branch information
devcatalin committed Sep 29, 2021
1 parent e5a19f2 commit 3538faf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/molecules/Monaco/Monaco.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const Monaco = (props: {editorHeight: string; diffSelectedResource: () => void;
const [hasWarnings, setWarnings] = useState(false);
const [isValid, setValid] = useState(true);
const [firstCodeLoadedOnEditor, setFirstCodeLoadedOnEditor] = useState(false);
const [isEditorMounted, setEditorMounted] = useState(false);

const editorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);
let editor = editorRef.current;
Expand All @@ -77,7 +78,7 @@ const Monaco = (props: {editorHeight: string; diffSelectedResource: () => void;
}
};

useCodeIntel(editor, code, selectedResourceId, resourceMap, fileMap, selectResource, selectFilePath);
useCodeIntel(editor, code, selectedResourceId, resourceMap, fileMap, isEditorMounted, selectResource, selectFilePath);
const {registerStaticActions} = useEditorKeybindings(
editor,
hiddenInputRef,
Expand Down Expand Up @@ -122,6 +123,7 @@ const Monaco = (props: {editorHeight: string; diffSelectedResource: () => void;
e.onDidChangeCursorSelection(onChangeCursorSelection);
e.revealLineNearTop(1);
e.setSelection(new monaco.Selection(0, 0, 0, 0));
setEditorMounted(true);
};

function onChange(newValue: any) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/molecules/Monaco/useCodeIntel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function useCodeIntel(
selectedResourceId: string | undefined,
resourceMap: ResourceMapType,
fileMap: FileMapType,
isEditorMounted: boolean,
selectResource: (resourceId: string) => void,
selectFilePath: (filePath: string) => void
) {
Expand Down Expand Up @@ -49,7 +50,7 @@ function useCodeIntel(
clearCodeIntel();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [code, selectedResourceId, resourceMap]);
}, [isEditorMounted, code, selectedResourceId, resourceMap]);

useEffect(() => {
if (completionDisposableRef.current && completionDisposableRef.current.dispose) {
Expand Down

0 comments on commit 3538faf

Please sign in to comment.