chore: add temporary debug info for code mirror (#2806)

chore: temp debug info
This commit is contained in:
Akash K
2022-10-20 17:17:54 +05:30
committed by GitHub
parent 6e7d28db7b
commit a950e08ef1

View File

@@ -40,6 +40,8 @@ import {
import { HoppEnvironmentPlugin } from "@helpers/editor/extensions/HoppEnvironment"
// TODO: Migrate from legacy mode
import { captureException } from "@sentry/vue"
type ExtendedEditorConfig = {
mode: string
placeholder: string
@@ -286,16 +288,31 @@ export function useCodemirror(
view.value?.destroy()
})
watch(value, (newVal) => {
watch(value, (newVal, oldVal) => {
if (cachedValue.value !== newVal) {
view.value?.dispatch({
filter: false,
changes: {
from: 0,
to: view.value.state.doc.length,
insert: newVal,
},
})
try {
view.value?.dispatch({
filter: false,
changes: {
from: 0,
to: view.value.state.doc.length,
insert: newVal,
},
})
} catch (e) {
captureException(e, {
extra: {
newVal,
oldVal,
changes: {
from: 0,
to: view.value?.state.doc.length,
insert: newVal,
cachedValue,
},
},
})
}
}
cachedValue.value = newVal
})