Skip to content

Commit ab07f4a

Browse files
committed
jump to clip
1 parent 969dcd0 commit ab07f4a

File tree

1 file changed

+44
-25
lines changed

1 file changed

+44
-25
lines changed

src/ui/code-editor.tsx

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,7 @@ export const CodeEditor = ({ width = 400, onWidthChange }: CodeEditorProps) => {
831831

832832
useEffect(() => {
833833
if (pendingJumpRef.current == null) return;
834+
if (!editorRef.current || !monacoRef.current) return;
834835
const { line, column } = pendingJumpRef.current;
835836
pendingJumpRef.current = null;
836837
revealPosition(line, column);
@@ -987,8 +988,8 @@ export const CodeEditor = ({ width = 400, onWidthChange }: CodeEditorProps) => {
987988
`}</style>
988989

989990
{/* Editor */}
990-
<div style={{ flex: 1, minHeight: 0 }}>
991-
{isLoading || !isVscodeReady ? (
991+
<div style={{ flex: 1, minHeight: 0, position: "relative" }}>
992+
{!isVscodeReady ? (
992993
<div
993994
style={{
994995
display: "flex",
@@ -1001,29 +1002,47 @@ export const CodeEditor = ({ width = 400, onWidthChange }: CodeEditorProps) => {
10011002
Loading editor...
10021003
</div>
10031004
) : (
1004-
<Editor
1005-
height="100%"
1006-
language={languageId}
1007-
value={code}
1008-
onChange={(value) => {
1009-
setCode(value || "");
1010-
setIsDirty(true);
1011-
}}
1012-
beforeMount={configureMonaco}
1013-
onMount={handleEditorDidMount}
1014-
path={currentFile}
1015-
theme="vs-dark"
1016-
options={{
1017-
minimap: { enabled: true },
1018-
fontSize: 14,
1019-
lineNumbers: "on",
1020-
roundedSelection: false,
1021-
scrollBeyondLastLine: false,
1022-
automaticLayout: true,
1023-
tabSize: 2,
1024-
wordWrap: "on",
1025-
}}
1026-
/>
1005+
<>
1006+
<Editor
1007+
height="100%"
1008+
language={languageId}
1009+
value={code}
1010+
onChange={(value) => {
1011+
setCode(value || "");
1012+
setIsDirty(true);
1013+
}}
1014+
beforeMount={configureMonaco}
1015+
onMount={handleEditorDidMount}
1016+
path={currentFile}
1017+
theme="vs-dark"
1018+
options={{
1019+
minimap: { enabled: true },
1020+
fontSize: 14,
1021+
lineNumbers: "on",
1022+
roundedSelection: false,
1023+
scrollBeyondLastLine: false,
1024+
automaticLayout: true,
1025+
tabSize: 2,
1026+
wordWrap: "on",
1027+
}}
1028+
/>
1029+
{isLoading && (
1030+
<div
1031+
style={{
1032+
position: "absolute",
1033+
inset: 0,
1034+
display: "flex",
1035+
alignItems: "center",
1036+
justifyContent: "center",
1037+
color: "#cccccc",
1038+
background: "rgba(15, 23, 42, 0.55)",
1039+
pointerEvents: "none",
1040+
}}
1041+
>
1042+
Loading editor...
1043+
</div>
1044+
)}
1045+
</>
10271046
)}
10281047
</div>
10291048
</div>

0 commit comments

Comments
 (0)