superfast cm.isBlank() instead of !cm.getValue().trim()
This commit is contained in:
parent
40f9413207
commit
102b5e03d4
|
@ -111,4 +111,16 @@
|
||||||
this.setOption('mode', MODE[preprocessor] || 'css');
|
this.setOption('mode', MODE[preprocessor] || 'css');
|
||||||
CodeMirror.autoLoadMode(this, MODE[preprocessor] || 'css');
|
CodeMirror.autoLoadMode(this, MODE[preprocessor] || 'css');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
CodeMirror.defineExtension('isBlank', function () {
|
||||||
|
// superfast checking as it runs only until the first non-blank line
|
||||||
|
let isBlank = true;
|
||||||
|
this.doc.eachLine(line => {
|
||||||
|
if (line.text && line.text.trim()) {
|
||||||
|
isBlank = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return isBlank;
|
||||||
|
});
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user