From be20b5a8b410e7d8c11ffe0ff76df359e017d0a8 Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 17 Dec 2017 21:56:35 +0300 Subject: [PATCH] match-highlighter: always use originalToken --- edit/match-highlighter-helper.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/edit/match-highlighter-helper.js b/edit/match-highlighter-helper.js index 72d91c58..34e598a4 100644 --- a/edit/match-highlighter-helper.js +++ b/edit/match-highlighter-helper.js @@ -146,7 +146,7 @@ } const sel = this.getSelection(); // current query differs from the selected text => remove the overlay - if (sel && rx && !rx.test(sel) || sel.toLowerCase() !== originalToken.toLowerCase()) { + if (sel && sel.toLowerCase() !== originalToken.toLowerCase()) { helper.query = helper.originalToken = sel; return; } @@ -158,14 +158,8 @@ const end = ch + queryLen; const string = this.getLine(line); const area = string.slice(start, end); - let startInArea; - if (rx) { - const m = area.match(rx); - startInArea = !m ? NaN : m.index + m[1].length; - } else { - const i = area.indexOf(query); - startInArea = i < 0 ? NaN : i; - } + const i = area.indexOf(query); + const startInArea = i < 0 ? NaN : i; if (isNaN(startInArea) || start + startInArea > ch || state.options.showToken.test(string[start + startInArea - 1] || '') || state.options.showToken.test(string[start + startInArea + queryLen] || '')) {