Fix: match-highlighter-helper is broken
This commit is contained in:
parent
4db8a9ea9a
commit
66967844c4
|
@ -364,15 +364,11 @@ input:invalid {
|
|||
.resize-grip-enabled .CodeMirror-scrollbar-filler {
|
||||
bottom: 7px; /* make space for resize-grip */
|
||||
}
|
||||
body[data-match-highlight="token"] .cm-matchhighlight-approved .cm-matchhighlight,
|
||||
body[data-match-highlight="token"] .CodeMirror-selection-highlight-scrollbar {
|
||||
.cm-matchhighlight-approved .cm-matchhighlight,
|
||||
.CodeMirror-selection-highlight-scrollbar {
|
||||
animation: fadein-match-highlighter 1s cubic-bezier(.97,.01,.42,.98);
|
||||
animation-fill-mode: both;
|
||||
}
|
||||
body[data-match-highlight="selection"] .cm-matchhighlight-approved .cm-matchhighlight,
|
||||
body[data-match-highlight="selection"] .CodeMirror-selection-highlight-scrollbar {
|
||||
background-color: rgba(1, 151, 193, 0.1);
|
||||
}
|
||||
@-webkit-keyframes highlight {
|
||||
from {
|
||||
background-color: #ff9;
|
||||
|
|
|
@ -158,7 +158,7 @@
|
|||
const end = ch + queryLen;
|
||||
const string = this.getLine(line);
|
||||
const area = string.slice(start, end);
|
||||
const i = area.indexOf(query);
|
||||
const i = matchIndex(area, query);
|
||||
const startInArea = i < 0 ? NaN : i;
|
||||
if (isNaN(startInArea) || start + startInArea > ch ||
|
||||
state.options.showToken.test(string[start + startInArea - 1] || '') ||
|
||||
|
@ -220,4 +220,12 @@
|
|||
return originalMatchesOnScrollbar.call(this, query, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
function matchIndex(s, needle) {
|
||||
if (typeof needle === 'string') {
|
||||
return s.indexOf(needle);
|
||||
}
|
||||
const match = s.match(needle);
|
||||
return match ? match.index + match[1].length : -1;
|
||||
}
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue
Block a user