From 8650d9966540107c97b845112967e0d256dc2660 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Thu, 23 Nov 2017 23:16:31 +0000 Subject: [PATCH] Disable linting above 1MB (Closes #608) --- app/ui/components/codemirror/code-editor.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/ui/components/codemirror/code-editor.js b/app/ui/components/codemirror/code-editor.js index 35baabc87..ff71b14aa 100644 --- a/app/ui/components/codemirror/code-editor.js +++ b/app/ui/components/codemirror/code-editor.js @@ -21,6 +21,7 @@ import * as xpath2 from '../../../common/xpath'; const TAB_KEY = 9; const TAB_SIZE = 4; +const MAX_SIZE_FOR_LINTING = 1000000; // Around 1MB const BASE_CODEMIRROR_OPTIONS = { lineNumbers: true, @@ -576,6 +577,14 @@ class CodeEditor extends React.Component { } const value = this.codeMirror.getDoc().getValue(); + + const lint = value.length > MAX_SIZE_FOR_LINTING ? false : !this.props.noLint; + const existingLint = this.codeMirror.options.lint || false; + console.log('LINT?', lint, value.length, MAX_SIZE_FOR_LINTING - value.length); + if (lint !== existingLint) { + this.codeMirror.setOption('lint', lint); + } + this.props.onChange(value); }