mirror of
https://litchi.icu/ngc2207/judge.git
synced 2025-05-18 20:07:41 +00:00
fix(playground): adjust layout of the editor component for improved responsiveness
This commit is contained in:
parent
5a9a20dee6
commit
c629dc5612
@ -172,35 +172,44 @@ export default function PlaygroundPage() {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Editor
|
<div className="flex flex-1 mt-0 m-3 gap-x-1">
|
||||||
theme="vs-dark"
|
<div className="w-1/3"></div>
|
||||||
path={file.name}
|
<div className="w-1/3">
|
||||||
defaultLanguage={file.language}
|
<Editor
|
||||||
defaultValue={file.value}
|
theme="vs-dark"
|
||||||
options={{ automaticLayout: true }}
|
path={file.name}
|
||||||
onMount={(editor) => {
|
defaultLanguage={file.language}
|
||||||
editorRef.current = editor;
|
defaultValue={file.value}
|
||||||
if (editorRef.current) {
|
options={{ automaticLayout: true }}
|
||||||
const model = editorRef.current.getModel();
|
onMount={(editor) => {
|
||||||
if (model) {
|
editorRef.current = editor;
|
||||||
const lineCount = model.getLineCount();
|
if (editorRef.current) {
|
||||||
const lastLineLength = model.getLineLength(lineCount);
|
const model = editorRef.current.getModel();
|
||||||
editorRef.current.setPosition({
|
if (model) {
|
||||||
lineNumber: lineCount,
|
const lineCount = model.getLineCount();
|
||||||
column: lastLineLength + 1,
|
const lastLineLength = model.getLineLength(lineCount);
|
||||||
});
|
editorRef.current.setPosition({
|
||||||
editorRef.current.focus();
|
lineNumber: lineCount,
|
||||||
connectToLanguageServer(language, webSocketRef)
|
column: lastLineLength + 1,
|
||||||
.then((languageClient) => {
|
});
|
||||||
languageClientRef.current = languageClient;
|
editorRef.current.focus();
|
||||||
})
|
connectToLanguageServer(language, webSocketRef)
|
||||||
.catch((error) => {
|
.then((languageClient) => {
|
||||||
console.error("Failed to connect to language server:", error);
|
languageClientRef.current = languageClient;
|
||||||
});
|
})
|
||||||
}
|
.catch((error) => {
|
||||||
}
|
console.error(
|
||||||
}}
|
"Failed to connect to language server:",
|
||||||
/>
|
error
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="w-1/3"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user