Merge branch 'master' of https://github.com/openstyles/stylus
This commit is contained in:
commit
54f6d31146
|
@ -388,7 +388,7 @@
|
|||
let sorting = false;
|
||||
let timer;
|
||||
// allow any types of elements between ours, except for the following:
|
||||
const ORDERED_TAGS = ['head', 'body', 'style', 'link'];
|
||||
const ORDERED_TAGS = ['head', 'body', 'frameset', 'style', 'link'];
|
||||
|
||||
init();
|
||||
return;
|
||||
|
@ -396,10 +396,7 @@
|
|||
function init() {
|
||||
docRootObserver = new MutationObserver(sortStyleElements);
|
||||
Object.assign(docRootObserver, {start, stop});
|
||||
if (!chrome.app) {
|
||||
// compensate for Firefox missing a step when loading the tab in background
|
||||
setTimeout(sortStyleElements);
|
||||
}
|
||||
setTimeout(sortStyleElements);
|
||||
}
|
||||
function start({sort = false} = {}) {
|
||||
if (sort && sortStyleMap()) {
|
||||
|
@ -434,26 +431,25 @@
|
|||
}
|
||||
}
|
||||
function sortStyleElements() {
|
||||
let expected = document.body || document.head;
|
||||
if (!expected || sorting) {
|
||||
let prevExpected = document.body || document.head;
|
||||
if (!prevExpected || sorting) {
|
||||
return;
|
||||
}
|
||||
for (const el of styleElements.values()) {
|
||||
if (!isMovable(el)) {
|
||||
continue;
|
||||
}
|
||||
let prev = el.previousElementSibling;
|
||||
while (prev !== expected) {
|
||||
if (prev && isSkippable(prev)) {
|
||||
expected = prev;
|
||||
prev = prev.nextElementSibling;
|
||||
} else if (!moveAfter(el, expected)) {
|
||||
return;
|
||||
} else {
|
||||
while (true) {
|
||||
const next = prevExpected.nextElementSibling;
|
||||
if (next && isSkippable(next)) {
|
||||
prevExpected = next;
|
||||
} else if (moveAfter(el, prevExpected)) {
|
||||
prevExpected = el;
|
||||
break;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
expected = el;
|
||||
}
|
||||
if (sorting) {
|
||||
sorting = false;
|
||||
|
|
|
@ -29,27 +29,36 @@
|
|||
const originalAddOverlay = CodeMirror.prototype.addOverlay;
|
||||
const originalRemoveOverlay = CodeMirror.prototype.removeOverlay;
|
||||
const originalMatchesOnScrollbar = CodeMirror.prototype.showMatchesOnScrollbar;
|
||||
const originalSetOption = CodeMirror.prototype.setOption;
|
||||
let originalGetOption;
|
||||
|
||||
CodeMirror.prototype.addOverlay = addOverlay;
|
||||
CodeMirror.prototype.removeOverlay = removeOverlay;
|
||||
CodeMirror.prototype.showMatchesOnScrollbar = matchesOnScrollbar;
|
||||
CodeMirror.prototype.setOption = setOption;
|
||||
|
||||
let enabled = Boolean(prefs.get('editor.matchHighlight'));
|
||||
|
||||
return;
|
||||
|
||||
function setOption(option, value) {
|
||||
enabled = option === 'highlightSelectionMatches' ? value : enabled;
|
||||
return originalSetOption.apply(this, arguments);
|
||||
}
|
||||
|
||||
function shouldIntercept(overlay) {
|
||||
const hlState = this.state.matchHighlighter || {};
|
||||
return overlay === hlState.overlay && (hlState.options || {}).showToken;
|
||||
}
|
||||
|
||||
function addOverlay() {
|
||||
return shouldIntercept.apply(this, arguments) &&
|
||||
return enabled && shouldIntercept.apply(this, arguments) &&
|
||||
addOverlayForHighlighter.apply(this, arguments) ||
|
||||
originalAddOverlay.apply(this, arguments);
|
||||
}
|
||||
|
||||
function removeOverlay() {
|
||||
return shouldIntercept.apply(this, arguments) &&
|
||||
return enabled && shouldIntercept.apply(this, arguments) &&
|
||||
removeOverlayForHighlighter.apply(this, arguments) ||
|
||||
originalRemoveOverlay.apply(this, arguments);
|
||||
}
|
||||
|
@ -181,6 +190,9 @@
|
|||
}
|
||||
|
||||
function matchesOnScrollbar(query, ...args) {
|
||||
if (!enabled) {
|
||||
return originalMatchesOnScrollbar.call(this, query, ...args);
|
||||
}
|
||||
const state = this.state.matchHighlighter;
|
||||
const helper = state.highlightHelper = state.highlightHelper || {};
|
||||
// rewrite the \btoken\b regexp so it matches .token and #token and --token
|
||||
|
|
Loading…
Reference in New Issue
Block a user