fix: useCodemirror getting non strings as value (#2810)

This commit is contained in:
Akash K
2022-10-22 12:36:07 +05:30
committed by GitHub
parent b61df04c1b
commit 9eac00b303
2 changed files with 32 additions and 12 deletions

View File

@@ -161,7 +161,7 @@ const getEditorLanguage = (
export function useCodemirror(
el: Ref<any | null>,
value: Ref<string>,
value: Ref<string | undefined>,
options: CodeMirrorOptions
): { cursor: Ref<{ line: number; ch: number }> } {
const { subscribeToStream } = useStreamSubscriber()
@@ -289,6 +289,15 @@ export function useCodemirror(
})
watch(value, (newVal, oldVal) => {
if (newVal === undefined) {
view.value?.destroy()
view.value = undefined
return
}
if (!view.value && el.value) {
initView(el.value)
}
if (cachedValue.value !== newVal) {
try {
view.value?.dispatch({