From a950e08ef1e5a0196df4378a596d831d0bacb797 Mon Sep 17 00:00:00 2001 From: Akash K <57758277+amk-dev@users.noreply.github.com> Date: Thu, 20 Oct 2022 17:17:54 +0530 Subject: [PATCH] chore: add temporary debug info for code mirror (#2806) chore: temp debug info --- .../src/composables/codemirror.ts | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/packages/hoppscotch-app/src/composables/codemirror.ts b/packages/hoppscotch-app/src/composables/codemirror.ts index 440b7cba8..be2953e67 100644 --- a/packages/hoppscotch-app/src/composables/codemirror.ts +++ b/packages/hoppscotch-app/src/composables/codemirror.ts @@ -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 })