Skip to content

Commit

Permalink
BUGFIX: Cursor position in editor is moved undesirably in edge cases (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
catloversg authored Feb 7, 2025
1 parent 48bced3 commit c99fa44
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ScriptEditor/ui/ScriptEditorRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@ function Root(props: IProps): React.ReactElement {
}
if (needToReloadModel) {
const currentModel = editorRef.current.getModel();
// Save the current cursor position. The position resets when the model is changed.
const currentPosition = editorRef.current.getPosition();
// Reload the model.
currentModel?.setValue(currentModel.getValue());
// Restore the saved position.
if (currentPosition) {
editorRef.current.setPosition(currentPosition);
}
}
}, 2000);

Expand Down

0 comments on commit c99fa44

Please sign in to comment.