mirror of
https://litchi.icu/ngc2207/judge.git
synced 2025-05-18 20:27:42 +00:00
fix(playground): ensure editor focus and position handling only occurs if editor is initialized
This commit is contained in:
parent
3737a708f6
commit
0bc5758d44
@ -117,15 +117,17 @@ export default function PlaygroundPage() {
|
||||
options={{ automaticLayout: true }}
|
||||
onMount={(editor) => {
|
||||
editorRef.current = editor;
|
||||
const model = editorRef.current.getModel();
|
||||
if (model) {
|
||||
const lineCount = model.getLineCount();
|
||||
const lastLineLength = model.getLineLength(lineCount);
|
||||
editorRef.current.setPosition({
|
||||
lineNumber: lineCount,
|
||||
column: lastLineLength + 1,
|
||||
});
|
||||
editorRef.current.focus();
|
||||
if (editorRef.current) {
|
||||
const model = editorRef.current.getModel();
|
||||
if (model) {
|
||||
const lineCount = model.getLineCount();
|
||||
const lastLineLength = model.getLineLength(lineCount);
|
||||
editorRef.current.setPosition({
|
||||
lineNumber: lineCount,
|
||||
column: lastLineLength + 1,
|
||||
});
|
||||
editorRef.current.focus();
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user