CodeMirror speedup: reuse the old folding marks

This commit is contained in:
tophf 2019-09-23 11:50:37 +03:00
parent 57c261c063
commit 96a6985032

View File

@ -242,6 +242,20 @@
CodeMirror.commands[name] = (...args) => editor[name](...args);
}
// speedup: reuse the old folding marks
const {setGutterMarker} = CodeMirror.prototype;
CodeMirror.prototype.setGutterMarker = function (line, gutterID, value) {
const o = this.state.foldGutter.options;
if (typeof o.indicatorOpen === 'string' ||
typeof o.indicatorFolded === 'string') {
const old = line.gutterMarkers && line.gutterMarkers[gutterID];
if (old ? value && value.className === old.className : !value) {
return line;
}
}
return setGutterMarker.apply(this, arguments);
};
// CodeMirror convenience commands
Object.assign(CodeMirror.commands, {
toggleEditorFocus,