Skip to content

Commit 78f6f7e

Browse files
fix(editor): update editor value only if snippet id is changed (#228)
1 parent 5cc3dfa commit 78f6f7e

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/renderer/components/editor/EditorCodemirror.vue

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ const clearAllMarks = () => {
232232
}
233233
}
234234
235+
const clearHistory = () => {
236+
if (!editor) return
237+
editor.clearHistory()
238+
}
239+
235240
const format = async () => {
236241
const availableLang: Language[] = [
237242
'css',
@@ -285,22 +290,15 @@ const hideScrollbar = useDebounceFn(() => {
285290
}, 1000)
286291
287292
watch(
288-
() => props.modelValue,
293+
() => [props.snippetId, props.fragmentIndex],
289294
() => {
290295
setValue(props.modelValue)
291296
292297
if (snippetStore.searchQuery) {
293298
findAll(snippetStore.searchQuery)
294299
}
295-
}
296-
)
297300
298-
watch(
299-
() => [props.snippetId, props.fragmentIndex].concat(),
300-
() => {
301-
if (editor) {
302-
editor.clearHistory()
303-
}
301+
clearHistory()
304302
}
305303
)
306304

0 commit comments

Comments
 (0)