Skip to content

Commit

Permalink
Dispatch ChangeSet instead of creating new EditorState on resetView i…
Browse files Browse the repository at this point in the history
…n CodeBlock (#2243)
  • Loading branch information
laurakwhit authored Jul 30, 2024
1 parent 5f41480 commit af0d545
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib/holocene/code-block.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,13 @@
export const resetView = (value = '', format = true) => {
const formattedValue = format ? formatValue({ value, language }) : value;
const newState = createEditorState(formattedValue);
view.setState(newState);
view.dispatch({
changes: {
from: 0,
to: view.state.doc.length,
insert: formattedValue,
},
});
};
const setView = () => {
Expand Down

0 comments on commit af0d545

Please sign in to comment.