Skip to content

Commit 6a1b153

Browse files
committed
fix editor init
1 parent 4fe68e9 commit 6a1b153

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

packages/editor/src/lib/Editor.svelte

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
}
109109
110110
state = EditorState.create({
111-
doc: file.contents,
111+
doc: '\n',
112112
extensions: [
113113
...extensions,
114114
...(lang || []),
@@ -118,6 +118,7 @@
118118
});
119119
120120
editor_states.set(file.name, state);
121+
select_state(file.name);
121122
}
122123
}
123124
}
@@ -135,13 +136,11 @@
135136
136137
function select_state(selected_name: string | null) {
137138
const state =
138-
(selected_name && editor_states.get(selected_name)) ||
139-
EditorState.create({
140-
doc: '',
141-
extensions: [EditorState.readOnly.of(true)]
142-
});
139+
(selected_name && editor_states.get(selected_name))
143140
144-
editor_view.setState(state);
141+
if (state) {
142+
editor_view.setState(state);
143+
}
145144
}
146145
147146
$effect(() => {

0 commit comments

Comments
 (0)