Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

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

Akash Ka950e08ef1e5
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
})