Skip to content

Commit

Permalink
Merge pull request #1890 from codecrafters-io/code-mirror/fix-line-se…
Browse files Browse the repository at this point in the history
…parator-option
  • Loading branch information
VasylMarchuk committed Jun 22, 2024
2 parents cc2bd37 + 3e35061 commit 6a8c962
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 6a8c962

Please sign in to comment.