mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 23:08:36 +02:00
BUGFIX: Cursor position in editor is moved undesirably in edge cases (#1952)
This commit is contained in:
@@ -111,7 +111,14 @@ function Root(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
if (needToReloadModel) {
|
if (needToReloadModel) {
|
||||||
const currentModel = editorRef.current.getModel();
|
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());
|
currentModel?.setValue(currentModel.getValue());
|
||||||
|
// Restore the saved position.
|
||||||
|
if (currentPosition) {
|
||||||
|
editorRef.current.setPosition(currentPosition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user