From 14dbfdd915c530a27dce1adfb9def2d3cabdd3bf Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 15 Nov 2017 08:32:22 +0300 Subject: [PATCH] update applies-to widget on any style changes --- edit/applies-to-line-widget.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/edit/applies-to-line-widget.js b/edit/applies-to-line-widget.js index 99233943..195845b8 100644 --- a/edit/applies-to-line-widget.js +++ b/edit/applies-to-line-widget.js @@ -38,6 +38,7 @@ function createAppliesToLineWidget(cm) { // is it possible to avoid flickering? window.addEventListener('load', updateWidgetStyle); + chrome.runtime.onMessage.addListener(onRuntimeMessage); update(); } @@ -50,6 +51,7 @@ function createAppliesToLineWidget(cm) { cm.off('change', onChange); cm.off('optionChange', onOptionChange); window.removeEventListener('load', updateWidgetStyle); + chrome.runtime.onMessage.removeListener(onRuntimeMessage); } 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() { cm.operation(doUpdate); }