superfast cm.isBlank() instead of !cm.getValue().trim()

This commit is contained in:
tophf 2017-11-15 02:50:53 +03:00
parent 40f9413207
commit 102b5e03d4

View File

@ -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;
});
})(); })();