Skip to content

Commit

Permalink
Reload @document in CodeMirror component when @lineSeparator ch…
Browse files Browse the repository at this point in the history
…anges
  • Loading branch information
VasylMarchuk committed Jun 22, 2024
1 parent cc2bd37 commit 3e35061
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/components/code-mirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,19 @@ export default class CodeMirrorComponent extends Component<Signature> {
this.renderedView?.dispatch({
effects: compartment?.reconfigure(handlerMethod ? await handlerMethod(newValue as undefined, this.args, optionName) : []),
});

// some options need the document to be re-loaded after being applied
if (['lineSeparator'].includes(optionName)) {
this.renderedView?.dispatch(
this.renderedView?.state.update({
changes: {
from: 0,
to: this.renderedView.state.doc.length,
insert: this.args.document,
},
}),
);
}
}

@action async renderEditor(element: Element) {
Expand Down

0 comments on commit 3e35061

Please sign in to comment.