From 4a0f74764a7cea57b922564f717a753906f81ad2 Mon Sep 17 00:00:00 2001 From: tophf Date: Sat, 11 Sep 2021 15:58:59 +0300 Subject: [PATCH] update regexp report when tab is removed --- edit/regexp-tester.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/edit/regexp-tester.js b/edit/regexp-tester.js index 3879f178..bc940758 100644 --- a/edit/regexp-tester.js +++ b/edit/regexp-tester.js @@ -18,7 +18,8 @@ const regexpTester = (() => { if (state && !isShown) { if (!isWatching) { isWatching = true; - chrome.tabs.onUpdated.addListener(onTabUpdate); + chrome.tabs.onRemoved.addListener(onTabRemoved); + chrome.tabs.onUpdated.addListener(onTabUpdated); } helpPopup.show('', $create('.regexp-report')); window.on('closeHelp', () => regexpTester.toggle(false), {once: true}); @@ -167,7 +168,11 @@ const regexpTester = (() => { } } - function onTabUpdate(tabId, info) { + function onTabRemoved() { + regexpTester.update(); + } + + function onTabUpdated(tabId, info) { if (info.url) { regexpTester.update(); } @@ -175,7 +180,8 @@ const regexpTester = (() => { function unwatch() { if (isWatching) { - chrome.tabs.onUpdated.removeListener(onTabUpdate); + chrome.tabs.onRemoved.removeListener(onTabRemoved); + chrome.tabs.onUpdated.removeListener(onTabUpdated); isWatching = false; } }