From 5fdfce79549253869d80025873464309092ce6c8 Mon Sep 17 00:00:00 2001 From: Jason <23126557+dyckia@users.noreply.github.com> Date: Sat, 10 Jul 2021 16:01:15 -0230 Subject: [PATCH 1/7] Add feature: close one tab on the left/right --- background_scripts/commands.js | 9 ++++++++- background_scripts/main.js | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) mode change 100644 => 100755 background_scripts/commands.js mode change 100644 => 100755 background_scripts/main.js diff --git a/background_scripts/commands.js b/background_scripts/commands.js old mode 100644 new mode 100755 index a6715f5f8..a453810c8 --- a/background_scripts/commands.js +++ b/background_scripts/commands.js @@ -243,7 +243,10 @@ const Commands = { "removeTab", "restoreTab", "moveTabToNewWindow", - "closeTabsOnLeft","closeTabsOnRight", + "closeTabsOnLeft", + "closeOneTabOnLeft", + "closeTabsOnRight", + "closeOneTabOnRight", "closeOtherTabs", "moveTabLeft", "moveTabRight"], @@ -274,7 +277,9 @@ const Commands = { "moveTabLeft", "moveTabRight", "closeTabsOnLeft", + "closeOneTabOnLeft", "closeTabsOnRight", + "closeOneTabOnRight", "closeOtherTabs", "enterVisualLineMode", "toggleViewSource", @@ -437,7 +442,9 @@ const commandDescriptions = { toggleMuteTab: ["Mute or unmute current tab", { background: true, noRepeat: true }], closeTabsOnLeft: ["Close tabs on the left", {background: true, noRepeat: true}], + closeOneTabOnLeft: ["Close one tab on the left", {background: true, noRepeat: true}], closeTabsOnRight: ["Close tabs on the right", {background: true, noRepeat: true}], + closeOneTabOnRight: ["Close one tab on the right", {background: true, noRepeat: true}], closeOtherTabs: ["Close all other tabs", {background: true, noRepeat: true}], moveTabLeft: ["Move tab to the left", { background: true }], diff --git a/background_scripts/main.js b/background_scripts/main.js old mode 100644 new mode 100755 index dd569d129..df202fed8 --- a/background_scripts/main.js +++ b/background_scripts/main.js @@ -325,7 +325,9 @@ const BackgroundCommands = { }, closeTabsOnLeft(request) { return removeTabsRelative("before", request); }, + closeOneTabOnLeft(request) { return removeTabsRelative("beforeOne", request); }, closeTabsOnRight(request) { return removeTabsRelative("after", request); }, + closeOneTabOnRight(request) { return removeTabsRelative("afterOne", request); }, closeOtherTabs(request) { return removeTabsRelative("both", request); }, visitPreviousTab({count, tab}) { @@ -365,8 +367,12 @@ var removeTabsRelative = (direction, {tab: activeTab}) => chrome.tabs.query({cur (() => { switch (direction) { case "before": return index => index < activeTab.index; + case "beforeOne": + return index => index == activeTab.index - 1; case "after": return index => index > activeTab.index; + case "afterOne": + return index => index == activeTab.index + 1; case "both": return index => index !== activeTab.index; } })(); From 0c4d7fd162cc00cce0055fb0bf958c4db5139b0c Mon Sep 17 00:00:00 2001 From: Jason <23126557+dyckia@users.noreply.github.com> Date: Mon, 19 Jul 2021 21:55:57 -0230 Subject: [PATCH 2/7] Add repeat feature to closeOneTabOnLeft and closeOneTabOnRight --- background_scripts/commands.js | 4 ++-- background_scripts/main.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/background_scripts/commands.js b/background_scripts/commands.js index a453810c8..59811fb8d 100755 --- a/background_scripts/commands.js +++ b/background_scripts/commands.js @@ -442,9 +442,9 @@ const commandDescriptions = { toggleMuteTab: ["Mute or unmute current tab", { background: true, noRepeat: true }], closeTabsOnLeft: ["Close tabs on the left", {background: true, noRepeat: true}], - closeOneTabOnLeft: ["Close one tab on the left", {background: true, noRepeat: true}], + closeOneTabOnLeft: ["Close one tab on the left", {background: true}], closeTabsOnRight: ["Close tabs on the right", {background: true, noRepeat: true}], - closeOneTabOnRight: ["Close one tab on the right", {background: true, noRepeat: true}], + closeOneTabOnRight: ["Close one tab on the right", {background: true}], closeOtherTabs: ["Close all other tabs", {background: true, noRepeat: true}], moveTabLeft: ["Move tab to the left", { background: true }], diff --git a/background_scripts/main.js b/background_scripts/main.js index df202fed8..69df36564 100755 --- a/background_scripts/main.js +++ b/background_scripts/main.js @@ -362,17 +362,17 @@ var forCountTabs = (count, currentTab, callback) => chrome.tabs.query({currentWi }); // Remove tabs before, after, or either side of the currently active tab -var removeTabsRelative = (direction, {tab: activeTab}) => chrome.tabs.query({currentWindow: true}, function(tabs) { +var removeTabsRelative = (direction, {count, tab: activeTab}) => chrome.tabs.query({currentWindow: true}, function(tabs) { const shouldDelete = (() => { switch (direction) { case "before": return index => index < activeTab.index; case "beforeOne": - return index => index == activeTab.index - 1; + return index => index < activeTab.index && index >= activeTab.index - count; case "after": return index => index > activeTab.index; case "afterOne": - return index => index == activeTab.index + 1; + return index => index > activeTab.index && index <= activeTab.index + count; case "both": return index => index !== activeTab.index; } })(); From 6ee8174e710780ac5ffb394965c22344852a6877 Mon Sep 17 00:00:00 2001 From: Jason <23126557+dyckia@users.noreply.github.com> Date: Fri, 23 Jul 2021 13:27:10 -0230 Subject: [PATCH 3/7] change half page amout to 0.6 --- content_scripts/mode_normal.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content_scripts/mode_normal.js b/content_scripts/mode_normal.js index ad6abd5dd..37383dde1 100644 --- a/content_scripts/mode_normal.js +++ b/content_scripts/mode_normal.js @@ -70,8 +70,8 @@ var NormalModeCommands = { scrollToRight() { Scroller.scrollTo("x", "max"); }, scrollUp(count) { Scroller.scrollBy("y", -1 * Settings.get("scrollStepSize") * count); }, scrollDown(count) { Scroller.scrollBy("y", Settings.get("scrollStepSize") * count); }, - scrollPageUp(count) { Scroller.scrollBy("y", "viewSize", (-1/2) * count); }, - scrollPageDown(count) { Scroller.scrollBy("y", "viewSize", (1/2) * count); }, + scrollPageUp(count) { Scroller.scrollBy("y", "viewSize", (-1.2/2) * count); }, + scrollPageDown(count) { Scroller.scrollBy("y", "viewSize", (1.2/2) * count); }, scrollFullPageUp(count) { Scroller.scrollBy("y", "viewSize", -1 * count); }, scrollFullPageDown(count) { Scroller.scrollBy("y", "viewSize", 1 * count); }, scrollLeft(count) { Scroller.scrollBy("x", -1 * Settings.get("scrollStepSize") * count); }, From d6f1e8aefa4ee387ed34979726d5199106bd9808 Mon Sep 17 00:00:00 2001 From: Jason <23126557+dyckia@users.noreply.github.com> Date: Sat, 24 Jul 2021 16:14:42 -0230 Subject: [PATCH 4/7] Add feature closeOneTabeSelf --- background_scripts/commands.js | 6 ++++++ background_scripts/main.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/background_scripts/commands.js b/background_scripts/commands.js index 59811fb8d..d299e4d17 100755 --- a/background_scripts/commands.js +++ b/background_scripts/commands.js @@ -245,8 +245,10 @@ const Commands = { "moveTabToNewWindow", "closeTabsOnLeft", "closeOneTabOnLeft", + "closeOneTabOnLeftAndSelf", "closeTabsOnRight", "closeOneTabOnRight", + "closeOneTabOnRightAndSelf", "closeOtherTabs", "moveTabLeft", "moveTabRight"], @@ -278,8 +280,10 @@ const Commands = { "moveTabRight", "closeTabsOnLeft", "closeOneTabOnLeft", + "closeOneTabOnLeftAndSelf", "closeTabsOnRight", "closeOneTabOnRight", + "closeOneTabOnRightAndSelf", "closeOtherTabs", "enterVisualLineMode", "toggleViewSource", @@ -443,8 +447,10 @@ const commandDescriptions = { closeTabsOnLeft: ["Close tabs on the left", {background: true, noRepeat: true}], closeOneTabOnLeft: ["Close one tab on the left", {background: true}], + closeOneTabOnLeftAndSelf: ["Close one tab on the left and itself", {background: true}], closeTabsOnRight: ["Close tabs on the right", {background: true, noRepeat: true}], closeOneTabOnRight: ["Close one tab on the right", {background: true}], + closeOneTabOnRightAndSelf: ["Close one tab on the right and itself", {background: true}], closeOtherTabs: ["Close all other tabs", {background: true, noRepeat: true}], moveTabLeft: ["Move tab to the left", { background: true }], diff --git a/background_scripts/main.js b/background_scripts/main.js index 69df36564..645761d14 100755 --- a/background_scripts/main.js +++ b/background_scripts/main.js @@ -326,8 +326,10 @@ const BackgroundCommands = { closeTabsOnLeft(request) { return removeTabsRelative("before", request); }, closeOneTabOnLeft(request) { return removeTabsRelative("beforeOne", request); }, + closeOneTabOnLeftAndSelf(request) { return removeTabsRelative("beforeOneAndSelf", request); }, closeTabsOnRight(request) { return removeTabsRelative("after", request); }, closeOneTabOnRight(request) { return removeTabsRelative("afterOne", request); }, + closeOneTabOnRightAndSelf(request) { return removeTabsRelative("afterOneAndSelf", request); }, closeOtherTabs(request) { return removeTabsRelative("both", request); }, visitPreviousTab({count, tab}) { @@ -369,10 +371,14 @@ var removeTabsRelative = (direction, {count, tab: activeTab}) => chrome.tabs.que return index => index < activeTab.index; case "beforeOne": return index => index < activeTab.index && index >= activeTab.index - count; + case "beforeOneAndSelf": + return index => index <= activeTab.index && index >= activeTab.index - count; case "after": return index => index > activeTab.index; case "afterOne": return index => index > activeTab.index && index <= activeTab.index + count; + case "afterOneAndSelf": + return index => index >= activeTab.index && index <= activeTab.index + count; case "both": return index => index !== activeTab.index; } })(); From 0b8cb43492f81d09b8553de51e8e5cee7d158364 Mon Sep 17 00:00:00 2001 From: Jason <23126557+dyckia@users.noreply.github.com> Date: Tue, 28 Sep 2021 00:05:33 -0230 Subject: [PATCH 5/7] Add vim bar suggestion for window --- background_scripts/commands.js | 3 ++ background_scripts/completion.js | 62 ++++++++++++++++++++++++++++++++ background_scripts/main.js | 16 +++++++-- content_scripts/mode_normal.js | 1 + content_scripts/vomnibar.js | 7 ++++ pages/vomnibar.js | 20 ++++++----- 6 files changed, 98 insertions(+), 11 deletions(-) diff --git a/background_scripts/commands.js b/background_scripts/commands.js index d299e4d17..4dac28d1c 100755 --- a/background_scripts/commands.js +++ b/background_scripts/commands.js @@ -225,6 +225,7 @@ const Commands = { "Vomnibar.activateBookmarks", "Vomnibar.activateBookmarksInNewTab", "Vomnibar.activateTabSelection", + "Vomnibar.moveTabToWindow", "Vomnibar.activateEditUrl", "Vomnibar.activateEditUrlInNewTab"], findCommands: ["enterFindMode", "performFind", "performBackwardsFind"], @@ -334,6 +335,7 @@ const defaultKeyMappings = { "o": "Vomnibar.activate", "O": "Vomnibar.activateInNewTab", "T": "Vomnibar.activateTabSelection", + "w": "Vomnibar.moveTabToWindow", "b": "Vomnibar.activateBookmarks", "B": "Vomnibar.activateBookmarksInNewTab", "ge": "Vomnibar.activateEditUrl", @@ -459,6 +461,7 @@ const commandDescriptions = { "Vomnibar.activate": ["Open URL, bookmark or history entry", { topFrame: true }], "Vomnibar.activateInNewTab": ["Open URL, bookmark or history entry in a new tab", { topFrame: true }], "Vomnibar.activateTabSelection": ["Search through your open tabs", { topFrame: true }], + "Vomnibar.moveTabToWindow": ["Move current tab to an existing window", { topFrame: true }], "Vomnibar.activateBookmarks": ["Open a bookmark", { topFrame: true }], "Vomnibar.activateBookmarksInNewTab": ["Open a bookmark in a new tab", { topFrame: true }], "Vomnibar.activateEditUrl": ["Edit the current URL", { topFrame: true }], diff --git a/background_scripts/completion.js b/background_scripts/completion.js index 1f9685cd8..8604bbad4 100644 --- a/background_scripts/completion.js +++ b/background_scripts/completion.js @@ -490,6 +490,67 @@ class TabCompleter { } } +// Searches through all windows, matching on title and URL. +class WindowCompleter { + filter({ name, queryTerms }, onComplete) { + if ((name !== "windows") && (queryTerms.length === 0)) + return onComplete([]); + + // chrome.tabs.query({}, tabs => { + // const results = tabs.filter(tab => RankingUtils.matches(queryTerms, tab.url, tab.title)); + // const suggestions = results.map(tab => { + // const suggestion = new Suggestion({ + // queryTerms, + // type: "tab", + // url: tab.url, + // title: tab.title, + // tabId: tab.id, + // deDuplicate: false + // }); + // suggestion.relevancy = this.computeRelevancy(suggestion); + // return suggestion; + // }).sort((a, b) => b.relevancy - a.relevancy); + + chrome.windows.getAll({populate: true}, windows => { + const curTabId = chrome.tabs.getCurrent(tab => tab.id); + const results = windows.filter(window => RankingUtils.matches(queryTerms, window.tabs[0].url, window.tabs[0].title)); + const suggestions = results.map(window => { + const suggestion = new Suggestion({ + queryTerms, + type: "window", + url: window.tabs[0].url, + title: window.tabs[0].title, + tabId: curTabId, + windowId: window.id, + deDuplicate: false, + }); + suggestion.relevancy = this.computeRelevancy(suggestion); + return suggestion; + }).sort((a, b) => b.relevancy - a.relevancy); + // Boost relevancy with a multiplier so a relevant tab doesn't + // get crowded out by results from competing completers. To + // prevent tabs from crowding out everything else in turn, + // penalize them for being further down the results list by + // scaling on a hyperbola starting at 1 and approaching 0 + // asymptotically for higher indexes. The multiplier and the + // curve fall-off were objectively chosen on the grounds that + // they seem to work pretty well. + suggestions.forEach(function(suggestion,i) { + suggestion.relevancy *= 8; + return suggestion.relevancy /= ( (i / 4) + 1 ); + }); + onComplete(suggestions); + }); + } + + computeRelevancy(suggestion) { + if (suggestion.queryTerms.length) + return RankingUtils.wordRelevancy(suggestion.queryTerms, suggestion.url, suggestion.title); + else + return BgUtils.tabRecency.recencyScore(suggestion.tabId); + } +} + class SearchEngineCompleter { constructor() { this.previousSuggestions = null; @@ -1091,6 +1152,7 @@ Object.assign(global, { HistoryCompleter, DomainCompleter, TabCompleter, + WindowCompleter, SearchEngineCompleter, HistoryCache, RankingUtils, diff --git a/background_scripts/main.js b/background_scripts/main.js index 645761d14..daffcbcad 100755 --- a/background_scripts/main.js +++ b/background_scripts/main.js @@ -43,6 +43,7 @@ const completionSources = { history: new HistoryCompleter, domains: new DomainCompleter, tabs: new TabCompleter, + windows: new WindowCompleter, searchEngines: new SearchEngineCompleter }; @@ -52,10 +53,12 @@ const completers = { completionSources.history, completionSources.domains, completionSources.tabs, - completionSources.searchEngines - ]), + completionSources.windows, + completionSources.searchEngines, + ]), bookmarks: new MultiCompleter([completionSources.bookmarks]), - tabs: new MultiCompleter([completionSources.tabs]) + tabs: new MultiCompleter([completionSources.tabs]), + windows: new MultiCompleter([completionSources.windows]), }; const completionHandlers = { @@ -225,6 +228,12 @@ const selectSpecificTab = request => chrome.tabs.get(request.id, function(tab) { return chrome.tabs.update(request.id, { active: true }); }); +const moveTabToSpecificWindow = request => chrome.tabs.move(request.tabId, {windowId: request.windowId, index: -1}, function(tab) { + if (chrome.windows != null) + chrome.windows.update(tab.windowId, { focused: true }); + return chrome.tabs.update(request.tabId, { active: true }); +}); + const moveTab = function({count, tab, registryEntry}) { if (registryEntry.command === "moveTabLeft") count = -count; @@ -641,6 +650,7 @@ var sendRequestHandlers = { frameFocused: handleFrameFocused, nextFrame: BackgroundCommands.nextFrame, selectSpecificTab, + moveTabToSpecificWindow, createMark: Marks.create.bind(Marks), gotoMark: Marks.goto.bind(Marks), // Send a message to all frames in the current tab. diff --git a/content_scripts/mode_normal.js b/content_scripts/mode_normal.js index 37383dde1..083bf0ec9 100644 --- a/content_scripts/mode_normal.js +++ b/content_scripts/mode_normal.js @@ -274,6 +274,7 @@ if (typeof Vomnibar !== 'undefined') { "Vomnibar.activate": Vomnibar.activate.bind(Vomnibar), "Vomnibar.activateInNewTab": Vomnibar.activateInNewTab.bind(Vomnibar), "Vomnibar.activateTabSelection": Vomnibar.activateTabSelection.bind(Vomnibar), + "Vomnibar.moveTabToWindow": Vomnibar.moveTabToWindow.bind(Vomnibar), "Vomnibar.activateBookmarks": Vomnibar.activateBookmarks.bind(Vomnibar), "Vomnibar.activateBookmarksInNewTab": Vomnibar.activateBookmarksInNewTab.bind(Vomnibar), "Vomnibar.activateEditUrl": Vomnibar.activateEditUrl.bind(Vomnibar), diff --git a/content_scripts/vomnibar.js b/content_scripts/vomnibar.js index 883ab4847..e5bac9308 100644 --- a/content_scripts/vomnibar.js +++ b/content_scripts/vomnibar.js @@ -31,6 +31,13 @@ const Vomnibar = { }); }, + moveTabToWindow(sourceFrameId) { + return this.open(sourceFrameId, { + completer: "windows", + selectFirst: true, + }); + }, + activateBookmarks(sourceFrameId) { return this.open(sourceFrameId, { completer: "bookmarks", diff --git a/pages/vomnibar.js b/pages/vomnibar.js index f0caa482e..c03f664a7 100644 --- a/pages/vomnibar.js +++ b/pages/vomnibar.js @@ -365,7 +365,8 @@ class BackgroundCompleter { this.name = name; this.completionActions = { navigateToUrl(url) { return openInNewTab => Vomnibar.getCompleter().launchUrl(url, openInNewTab); }, - switchToTab(tabId) { return () => chrome.runtime.sendMessage({handler: "selectSpecificTab", id: tabId}); } + switchToTab(tabId) { return () => chrome.runtime.sendMessage({handler: "selectSpecificTab", id: tabId}); }, + moveToWindow(tabId, windowId) { return () => chrome.runtime.sendMessage({handler: "moveTabToSpecificWindow", tabId: tabId, windowId: windowId}); } }; this.port = chrome.runtime.connect({name: "completions"}); @@ -381,14 +382,17 @@ class BackgroundCompleter { if (msg.id === this.messageId) { // The result objects coming from the background page will be of the form: // { html: "", type: "", url: "", ... } - // Type will be one of [tab, bookmark, history, domain, search], or a custom search engine description. + // Type will be one of [tab, bookmark, history, domain, search, window], or a custom search engine description. for (let result of msg.results) { - Object.assign(result, { - performAction: - result.type === "tab" ? - this.completionActions.switchToTab(result.tabId) : - this.completionActions.navigateToUrl(result.url) - }); + let completionAction; + if (result.type === "tab") { + completionAction = this.completionActions.switchToTab(result.tabId); + } else if (result.type === "window") { + completionAction = this.completionActions.moveToWindow(result.tabId, 1); + } else { + completionAction = this.completionActions.navigateToUrl(result.url); + } + Object.assign(result, { performAction: completionAction }); } // Handle the message, but only if it hasn't arrived too late. From 29452b8d5c50f57017fb4c1557487dbf0bff0e7f Mon Sep 17 00:00:00 2001 From: Jason <23126557+dyckia@users.noreply.github.com> Date: Tue, 28 Sep 2021 01:08:10 -0230 Subject: [PATCH 6/7] Add move tab function --- background_scripts/completion.js | 71 +++++++++++++------------------- background_scripts/main.js | 13 +++--- pages/vomnibar.js | 2 +- 3 files changed, 38 insertions(+), 48 deletions(-) diff --git a/background_scripts/completion.js b/background_scripts/completion.js index 8604bbad4..ee932dc56 100644 --- a/background_scripts/completion.js +++ b/background_scripts/completion.js @@ -496,50 +496,37 @@ class WindowCompleter { if ((name !== "windows") && (queryTerms.length === 0)) return onComplete([]); - // chrome.tabs.query({}, tabs => { - // const results = tabs.filter(tab => RankingUtils.matches(queryTerms, tab.url, tab.title)); - // const suggestions = results.map(tab => { - // const suggestion = new Suggestion({ - // queryTerms, - // type: "tab", - // url: tab.url, - // title: tab.title, - // tabId: tab.id, - // deDuplicate: false - // }); - // suggestion.relevancy = this.computeRelevancy(suggestion); - // return suggestion; - // }).sort((a, b) => b.relevancy - a.relevancy); - chrome.windows.getAll({populate: true}, windows => { - const curTabId = chrome.tabs.getCurrent(tab => tab.id); - const results = windows.filter(window => RankingUtils.matches(queryTerms, window.tabs[0].url, window.tabs[0].title)); - const suggestions = results.map(window => { - const suggestion = new Suggestion({ - queryTerms, - type: "window", - url: window.tabs[0].url, - title: window.tabs[0].title, - tabId: curTabId, - windowId: window.id, - deDuplicate: false, + chrome.tabs.query({currentWindow: true, active : true}, tabs => { + const curTab = tabs[0]; + const results = windows.filter(window => RankingUtils.matches(queryTerms, window.tabs[0].url, window.tabs[0].title)); + const suggestions = results.map(window => { + const suggestion = new Suggestion({ + queryTerms, + type: "window", + url: window.tabs[0].url, + title: window.tabs[0].title, + tabId: curTab.id, + windowId: window.id, + deDuplicate: false, + }); + suggestion.relevancy = this.computeRelevancy(suggestion); + return suggestion; + }).sort((a, b) => b.relevancy - a.relevancy); + // Boost relevancy with a multiplier so a relevant tab doesn't + // get crowded out by results from competing completers. To + // prevent tabs from crowding out everything else in turn, + // penalize them for being further down the results list by + // scaling on a hyperbola starting at 1 and approaching 0 + // asymptotically for higher indexes. The multiplier and the + // curve fall-off were objectively chosen on the grounds that + // they seem to work pretty well. + suggestions.forEach(function(suggestion,i) { + suggestion.relevancy *= 8; + return suggestion.relevancy /= ( (i / 4) + 1 ); }); - suggestion.relevancy = this.computeRelevancy(suggestion); - return suggestion; - }).sort((a, b) => b.relevancy - a.relevancy); - // Boost relevancy with a multiplier so a relevant tab doesn't - // get crowded out by results from competing completers. To - // prevent tabs from crowding out everything else in turn, - // penalize them for being further down the results list by - // scaling on a hyperbola starting at 1 and approaching 0 - // asymptotically for higher indexes. The multiplier and the - // curve fall-off were objectively chosen on the grounds that - // they seem to work pretty well. - suggestions.forEach(function(suggestion,i) { - suggestion.relevancy *= 8; - return suggestion.relevancy /= ( (i / 4) + 1 ); + onComplete(suggestions); }); - onComplete(suggestions); }); } @@ -547,7 +534,7 @@ class WindowCompleter { if (suggestion.queryTerms.length) return RankingUtils.wordRelevancy(suggestion.queryTerms, suggestion.url, suggestion.title); else - return BgUtils.tabRecency.recencyScore(suggestion.tabId); + return BgUtils.tabRecency.recencyScore(suggestion.windowId); } } diff --git a/background_scripts/main.js b/background_scripts/main.js index daffcbcad..7cd8894c8 100755 --- a/background_scripts/main.js +++ b/background_scripts/main.js @@ -228,11 +228,14 @@ const selectSpecificTab = request => chrome.tabs.get(request.id, function(tab) { return chrome.tabs.update(request.id, { active: true }); }); -const moveTabToSpecificWindow = request => chrome.tabs.move(request.tabId, {windowId: request.windowId, index: -1}, function(tab) { - if (chrome.windows != null) - chrome.windows.update(tab.windowId, { focused: true }); - return chrome.tabs.update(request.tabId, { active: true }); -}); +const moveTabToSpecificWindow = request => chrome.tabs.move(request.tabId, {windowId: request.windowId, index: -1}); + +// const moveTabToSpecificWindow = request => chrome.tabs.move(request.tabId, {windowId: request.windowId, index: -1}, function(tab) { +// console.log(request.tabId, request.windowId); +// if (chrome.windows != null) +// chrome.windows.update(request.windowId, { focused: true }); +// return chrome.tabs.update(request.tabId, { active: true }); +// }); const moveTab = function({count, tab, registryEntry}) { if (registryEntry.command === "moveTabLeft") diff --git a/pages/vomnibar.js b/pages/vomnibar.js index c03f664a7..268035a04 100644 --- a/pages/vomnibar.js +++ b/pages/vomnibar.js @@ -388,7 +388,7 @@ class BackgroundCompleter { if (result.type === "tab") { completionAction = this.completionActions.switchToTab(result.tabId); } else if (result.type === "window") { - completionAction = this.completionActions.moveToWindow(result.tabId, 1); + completionAction = this.completionActions.moveToWindow(result.tabId, result.windowId); } else { completionAction = this.completionActions.navigateToUrl(result.url); } From 372f6053a08ce0486656da35a14751e3ed95cb0c Mon Sep 17 00:00:00 2001 From: Jason <23126557+dyckia@users.noreply.github.com> Date: Tue, 28 Sep 2021 10:09:00 -0230 Subject: [PATCH 7/7] Filter omni bar results --- background_scripts/completion.js | 15 +++++++++------ background_scripts/main.js | 17 +++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/background_scripts/completion.js b/background_scripts/completion.js index ee932dc56..bcc0dfbea 100644 --- a/background_scripts/completion.js +++ b/background_scripts/completion.js @@ -497,17 +497,20 @@ class WindowCompleter { return onComplete([]); chrome.windows.getAll({populate: true}, windows => { - chrome.tabs.query({currentWindow: true, active : true}, tabs => { + chrome.tabs.query({currentWindow: true, active: true}, tabs => { const curTab = tabs[0]; - const results = windows.filter(window => RankingUtils.matches(queryTerms, window.tabs[0].url, window.tabs[0].title)); - const suggestions = results.map(window => { + // an array of active tabs for each window + const activeTabs = windows.filter(window => (curTab.windowId !== window.id) && (curTab.incognito === window.incognito)) + .map(window => window.tabs.find(tab => tab.active)); + const results = activeTabs.filter(activeTab => RankingUtils.matches(queryTerms, activeTab.url, activeTab.title)); + const suggestions = results.map(activeTab => { const suggestion = new Suggestion({ queryTerms, type: "window", - url: window.tabs[0].url, - title: window.tabs[0].title, + url: activeTab.url, + title: activeTab.title, tabId: curTab.id, - windowId: window.id, + windowId: activeTab.windowId, deDuplicate: false, }); suggestion.relevancy = this.computeRelevancy(suggestion); diff --git a/background_scripts/main.js b/background_scripts/main.js index 7cd8894c8..bc8f76fb2 100755 --- a/background_scripts/main.js +++ b/background_scripts/main.js @@ -228,14 +228,15 @@ const selectSpecificTab = request => chrome.tabs.get(request.id, function(tab) { return chrome.tabs.update(request.id, { active: true }); }); -const moveTabToSpecificWindow = request => chrome.tabs.move(request.tabId, {windowId: request.windowId, index: -1}); - -// const moveTabToSpecificWindow = request => chrome.tabs.move(request.tabId, {windowId: request.windowId, index: -1}, function(tab) { -// console.log(request.tabId, request.windowId); -// if (chrome.windows != null) -// chrome.windows.update(request.windowId, { focused: true }); -// return chrome.tabs.update(request.tabId, { active: true }); -// }); +// +// Move the tab with request.tabId to the window with request.windowId +// +const moveTabToSpecificWindow = request => { + // must focus window first, otherwise focus will shift to address bar + chrome.windows.update(request.windowId, { focused: true }); + chrome.tabs.move(request.tabId, {windowId: request.windowId, index: -1}); + chrome.tabs.update(request.tabId, { active: true }); +}; const moveTab = function({count, tab, registryEntry}) { if (registryEntry.command === "moveTabLeft")