Fix editor replace behavior (#1501)

## Launch Checklist

- Fixes #1492

This adds the relevant selection and scroll intoview parameters that
were previously missing as part of the migration to code mirror 6.
It fixes the replace part as described in the bug.

 - [x] Briefly describe the changes in this PR.
 - [x] Link to related issues.

While I think tests are needed here, I'm not sure there's an easy way to
actually test this because testing the code mirror editor is hard, and
even harder when there's key pressing (ctrl +F on windows and meta + F
on mac) involved...
This commit is contained in:
Harel M
2025-11-09 13:02:16 +02:00
committed by GitHub
parent 99e47cb387
commit 876a3d70df

View File

@@ -74,12 +74,15 @@ class InputJsonInternal extends React.Component<InputJsonInternalProps, InputJso
componentDidUpdate(prevProps: InputJsonProps) {
if (!this.state.isEditing && prevProps.value !== this.props.value) {
this._cancelNextChange = true;
const currentSelection = this._view!.state.selection;
this._view!.dispatch({
changes: {
from: 0,
to: this._view!.state.doc.length,
insert: this.getPrettyJson(this.props.value)
}
},
selection: currentSelection,
scrollIntoView: true
});
}
}