4x speed-up of showMatchesOnScrollbar
at the cost of a marginally reduced accuracy when line wrapping is enabled, but the difference shouldn't be more than a few pixels, presumably
This commit is contained in:
parent
a6fbc9db11
commit
b41cc8bca3
|
@ -5,8 +5,10 @@
|
|||
const HL_APPROVED = 'cm-matchhighlight-approved';
|
||||
const originalAddOverlay = CodeMirror.prototype.addOverlay;
|
||||
const originalRemoveOverlay = CodeMirror.prototype.removeOverlay;
|
||||
const originalMatchesOnScrollbar = CodeMirror.prototype.showMatchesOnScrollbar;
|
||||
CodeMirror.prototype.addOverlay = addOverlay;
|
||||
CodeMirror.prototype.removeOverlay = removeOverlay;
|
||||
CodeMirror.prototype.showMatchesOnScrollbar = matchesOnScrollbar;
|
||||
return;
|
||||
|
||||
function shouldIntercept(overlay) {
|
||||
|
@ -49,6 +51,16 @@
|
|||
};
|
||||
overlay.token = tokenHook;
|
||||
}
|
||||
|
||||
if (this.options.lineWrapping) {
|
||||
const originalGetOption = CodeMirror.prototype.getOption;
|
||||
CodeMirror.prototype.getOption = function (option) {
|
||||
return option !== 'lineWrapping' && originalGetOption.apply(this, arguments);
|
||||
};
|
||||
setTimeout(() => {
|
||||
CodeMirror.prototype.getOption = originalGetOption;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function tokenHook(stream) {
|
||||
|
@ -117,4 +129,9 @@
|
|||
this.showMatchesOnScrollbar = helper.showMatchesOnScrollbar;
|
||||
helper.query = query;
|
||||
}
|
||||
|
||||
function matchesOnScrollbar(query, ...args) {
|
||||
query = new RegExp(/(?:^|[^\w.#\\-])/.source + query.source.slice(2, -2) + /(?:[^\w.#\\-]|$)/.source);
|
||||
return originalMatchesOnScrollbar.call(this, query, ...args);
|
||||
}
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue
Block a user