diff --git a/packages/insomnia-app/app/ui/components/codemirror/code-editor.js b/packages/insomnia-app/app/ui/components/codemirror/code-editor.js index 669870ee3..2fac27a58 100644 --- a/packages/insomnia-app/app/ui/components/codemirror/code-editor.js +++ b/packages/insomnia-app/app/ui/components/codemirror/code-editor.js @@ -312,7 +312,13 @@ class CodeEditor extends React.Component { let startToken = '{'; let endToken = '}'; + // Prevent retrieving an invalid content if undefined + if (!from?.line || !to?.line) return '\u2194'; + const prevLine = this.codeMirror.getLine(from.line); + + if (!prevLine) return '\u2194'; + if (prevLine.lastIndexOf('[') > prevLine.lastIndexOf('{')) { startToken = '['; endToken = ']';