Skip to content

Commit af0d545

Browse files
authored
Dispatch ChangeSet instead of creating new EditorState on resetView in CodeBlock (#2243)
1 parent 5f41480 commit af0d545

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/lib/holocene/code-block.svelte

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,13 @@
159159
160160
export const resetView = (value = '', format = true) => {
161161
const formattedValue = format ? formatValue({ value, language }) : value;
162-
const newState = createEditorState(formattedValue);
163-
view.setState(newState);
162+
view.dispatch({
163+
changes: {
164+
from: 0,
165+
to: view.state.doc.length,
166+
insert: formattedValue,
167+
},
168+
});
164169
};
165170
166171
const setView = () => {

0 commit comments

Comments
 (0)