fix existing tab focus

This commit is contained in:
siikamiika 2020-02-09 22:16:52 +02:00
parent 21bad6c6e3
commit d4e74a0572

View File

@ -597,7 +597,7 @@ class Backend {
// Command handlers // Command handlers
async _onCommandSearch(params) { async _onCommandSearch(params) {
const {mode, query} = params || {mode: 'existingOrNewTab'}; const {mode='existingOrNewTab', query} = params || {};
const options = await this.getOptions(this.optionsContext); const options = await this.getOptions(this.optionsContext);
const {popupWidth, popupHeight} = options.general; const {popupWidth, popupHeight} = options.general;
@ -613,11 +613,14 @@ class Backend {
try { try {
const tab = await Backend._findTab(1000, (url2) => ( const tab = await Backend._findTab(1000, (url2) => (
url2 !== null && url2 !== null &&
url2.startsWith(url) && url2.startsWith(baseUrl) &&
(url2.length === url.length || url2[url.length] === '?' || url2[url.length] === '#') (url2.length === baseUrl.length || url2[baseUrl.length] === '?' || url2[baseUrl.length] === '#')
)); ));
if (tab !== null) { if (tab !== null) {
await Backend._focusTab(tab); await Backend._focusTab(tab);
if (queryParams.query) {
await new Promise((resolve) => chrome.tabs.update(tab.id, {url}, resolve));
}
return; return;
} }
} catch (e) { } catch (e) {