diff options
author | siikamiika <siikamiika@users.noreply.github.com> | 2020-02-09 22:16:52 +0200 |
---|---|---|
committer | siikamiika <siikamiika@users.noreply.github.com> | 2020-02-09 22:16:52 +0200 |
commit | d4e74a05723b1b4347c51606bcee61dc72e34e51 (patch) | |
tree | 93f7a00a95e970eb4615a769d4d1897fd34e99e2 /ext/bg/js | |
parent | 21bad6c6e380c9c0dbd03f82563a1570bf22963c (diff) |
fix existing tab focus
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/backend.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 6d23b695..9eb1d9ca 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -597,7 +597,7 @@ class Backend { // Command handlers async _onCommandSearch(params) { - const {mode, query} = params || {mode: 'existingOrNewTab'}; + const {mode='existingOrNewTab', query} = params || {}; const options = await this.getOptions(this.optionsContext); const {popupWidth, popupHeight} = options.general; @@ -613,11 +613,14 @@ class Backend { try { const tab = await Backend._findTab(1000, (url2) => ( url2 !== null && - url2.startsWith(url) && - (url2.length === url.length || url2[url.length] === '?' || url2[url.length] === '#') + url2.startsWith(baseUrl) && + (url2.length === baseUrl.length || url2[baseUrl.length] === '?' || url2[baseUrl.length] === '#') )); if (tab !== null) { await Backend._focusTab(tab); + if (queryParams.query) { + await new Promise((resolve) => chrome.tabs.update(tab.id, {url}, resolve)); + } return; } } catch (e) { |