Skip to content

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

fix: fix cursor going out of bounds when filtering response (#2850)

Akash K356fe4591f88
diff --git a/packages/hoppscotch-app/src/composables/codemirror.ts b/packages/hoppscotch-app/src/composables/codemirror.ts
index 564c28231..ae67c5023 100644
--- a/packages/hoppscotch-app/src/composables/codemirror.ts
+++ b/packages/hoppscotch-app/src/composables/codemirror.ts
@@ -195,21 +195,19 @@ export function useCodemirror(
ViewPlugin.fromClass(
class {
update(update: ViewUpdate) {
- if (update.selectionSet) {
- const cursorPos = update.state.selection.main.head
+ const cursorPos = update.state.selection.main.head
+ const line = update.state.doc.lineAt(cursorPos)
- const line = update.state.doc.lineAt(cursorPos)
-
- cachedCursor.value = {
- line: line.number - 1,
- ch: cursorPos - line.from,
- }
+ cachedCursor.value = {
+ line: line.number - 1,
+ ch: cursorPos - line.from,
+ }
- cursor.value = {
- line: cachedCursor.value.line,
- ch: cachedCursor.value.ch,
- }
+ cursor.value = {
+ line: cachedCursor.value.line,
+ ch: cachedCursor.value.ch,
}
+
if (update.docChanged) {
// Expensive on big files ?
cachedValue.value = update.state.doc