simpler plain string method for same token check
This commit is contained in:
parent
8bff4a297e
commit
3152a7ebfe
|
@ -69,11 +69,13 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const {line, ch} = this.getCursor();
|
const {line, ch} = this.getCursor();
|
||||||
const rx = query instanceof RegExp ? query : new RegExp(`\\b${query}\\b`);
|
const rx = query instanceof RegExp && query;
|
||||||
const start = Math.max(0, ch - rx.source.length + 4 + 1);
|
const queryLen = rx ? rx.source.length - 4 : query.length;
|
||||||
const end = ch + rx.source.length - 4;
|
const start = Math.max(0, ch - queryLen + 1);
|
||||||
|
const end = ch + queryLen;
|
||||||
const area = this.getLine(line).substring(start, end);
|
const area = this.getLine(line).substring(start, end);
|
||||||
const startInArea = (area.match(rx) || {}).index;
|
const startInArea = rx ? (area.match(rx) || {}).index :
|
||||||
|
(area.indexOf(query) + 1 || NaN) - 1;
|
||||||
if (start + startInArea <= ch) {
|
if (start + startInArea <= ch) {
|
||||||
// same token on cursor => prevent the highlighter from rerunning
|
// same token on cursor => prevent the highlighter from rerunning
|
||||||
state.stylusMHLHelper = {
|
state.stylusMHLHelper = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user