update applies-to widget on any style changes
This commit is contained in:
parent
9868a1819c
commit
14dbfdd915
|
@ -38,6 +38,7 @@ function createAppliesToLineWidget(cm) {
|
||||||
|
|
||||||
// is it possible to avoid flickering?
|
// is it possible to avoid flickering?
|
||||||
window.addEventListener('load', updateWidgetStyle);
|
window.addEventListener('load', updateWidgetStyle);
|
||||||
|
chrome.runtime.onMessage.addListener(onRuntimeMessage);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -50,6 +51,7 @@ function createAppliesToLineWidget(cm) {
|
||||||
cm.off('change', onChange);
|
cm.off('change', onChange);
|
||||||
cm.off('optionChange', onOptionChange);
|
cm.off('optionChange', onOptionChange);
|
||||||
window.removeEventListener('load', updateWidgetStyle);
|
window.removeEventListener('load', updateWidgetStyle);
|
||||||
|
chrome.runtime.onMessage.removeListener(onRuntimeMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onChange(cm, {from, to, origin}) {
|
function onChange(cm, {from, to, origin}) {
|
||||||
|
@ -72,6 +74,14 @@ function createAppliesToLineWidget(cm) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onRuntimeMessage(msg) {
|
||||||
|
if (msg.style || msg.styles ||
|
||||||
|
msg.prefs && 'disableAll' in msg.prefs ||
|
||||||
|
msg.method === 'styleDeleted') {
|
||||||
|
requestAnimationFrame(updateWidgetStyle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
cm.operation(doUpdate);
|
cm.operation(doUpdate);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user