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