proper partial match detection and display in showRegExpTester

closes #180
This commit is contained in:
tophf 2017-08-30 17:50:32 +03:00
parent 58b1c5be81
commit 3c5d20f862

View File

@ -1816,7 +1816,8 @@ function showRegExpTester(event, section = getSectionForChild(this)) {
const rxData = Object.assign({text}, cachedRegexps.get(text)); const rxData = Object.assign({text}, cachedRegexps.get(text));
if (!rxData.urls) { if (!rxData.urls) {
cachedRegexps.set(text, Object.assign(rxData, { cachedRegexps.set(text, Object.assign(rxData, {
rx: tryRegExp(text), // imitate buggy Stylish-for-chrome, see detectSloppyRegexps()
rx: tryRegExp('^' + text + '$'),
urls: new Map(), urls: new Map(),
})); }));
} }
@ -1882,6 +1883,7 @@ function showRegExpTester(event, section = getSectionForChild(this)) {
} else { } else {
partial.push($element({appendChild: [ partial.push($element({appendChild: [
icon, icon,
url.substr(0, match.index),
$element({tag: 'mark', textContent: match}), $element({tag: 'mark', textContent: match}),
url.substr(match.length), url.substr(match.length),
]})); ]}));