Fix for random UI crash (#2840)

Co-authored-by: Opender Singh <opender94@gmail.com>
Co-authored-by: Opender Singh <opender.singh@konghq.com>
This commit is contained in:
Giuseppe B 2020-11-24 05:40:36 +01:00 committed by GitHub
parent cf047322a9
commit e5a73190ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 = ']';