From 0c9be9291be3d192c63534c268c95a623b412248 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 10 May 2025 19:19:03 +0300 Subject: [PATCH] fix(code): set initial text --- .../widgets/type_widgets/abstract_code_type_widget.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts b/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts index 9614a3881..7324868b0 100644 --- a/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts +++ b/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts @@ -56,9 +56,13 @@ export default class AbstractCodeTypeWidget extends TypeWidget { * @param {*} content the new content of the note. */ _update(note: { mime: string }, content: string) { - // // CodeMirror breaks pretty badly on null, so even though it shouldn't happen (guarded by a consistency check) - // // we provide fallback - // this.codeEditor.setValue(content || ""); + this.codeEditor.dispatch({ + changes: { + from: 0, + to: this.codeEditor.state.doc.length, + insert: content || "", + } + }) // this.codeEditor.clearHistory(); // let info = CodeMirror.findModeByMIME(note.mime);