match-highlighter: do nothing if token is same
This commit is contained in:
parent
93695da69a
commit
fbc3ac0070
|
@ -119,16 +119,24 @@
|
||||||
function highlightMatches(cm) {
|
function highlightMatches(cm) {
|
||||||
cm.operation(function() {
|
cm.operation(function() {
|
||||||
var state = cm.state.matchHighlighter;
|
var state = cm.state.matchHighlighter;
|
||||||
removeOverlay(cm);
|
|
||||||
if (!cm.somethingSelected() && state.options.showToken) {
|
if (!cm.somethingSelected() && state.options.showToken) {
|
||||||
var re = state.options.showToken === true ? /[\w$]/ : state.options.showToken;
|
var re = state.options.showToken === true ? /[\w$]/ : state.options.showToken;
|
||||||
var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start;
|
var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start;
|
||||||
while (start && re.test(line.charAt(start - 1))) --start;
|
while (start && re.test(line.charAt(start - 1))) --start;
|
||||||
while (end < line.length && re.test(line.charAt(end))) ++end;
|
while (end < line.length && re.test(line.charAt(end))) ++end;
|
||||||
if (start < end)
|
/* STYLUS: hack start */
|
||||||
addOverlay(cm, line.slice(start, end), re, state.options.style);
|
const token = line.slice(start, end);
|
||||||
|
if (token !== state.lastToken) {
|
||||||
|
state.lastToken = token;
|
||||||
|
removeOverlay(cm);
|
||||||
|
if (token) {
|
||||||
|
addOverlay(cm, token, re, state.options.style);
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
removeOverlay(cm);
|
||||||
|
/* STYLUS: hack end */
|
||||||
var from = cm.getCursor("from"), to = cm.getCursor("to");
|
var from = cm.getCursor("from"), to = cm.getCursor("to");
|
||||||
if (from.line != to.line) return;
|
if (from.line != to.line) return;
|
||||||
if (state.options.wordsOnly && !isWord(cm, from, to)) return;
|
if (state.options.wordsOnly && !isWord(cm, from, to)) return;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user