From 2128ef3a4b6bb989323200578b230dfb1e178c2e Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 13 Feb 2018 14:43:25 +0000 Subject: Make the reload command accept a count. Move the `reload` command to the background page and make it accept a count prefix. Fixes #674. Althought the demand for this is low and the use cases limited, it is a very vim-ish extension to the existing command. --- background_scripts/main.coffee | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'background_scripts/main.coffee') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 70d97ca0..78bfce4c 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -235,6 +235,15 @@ BackgroundCommands = tabIds = BgUtils.tabRecency.getTabsByRecency().filter (tabId) -> tabId != tab.id if 0 < tabIds.length selectSpecificTab id: tabIds[(count-1) % tabIds.length] + reload: ({count, tabId, registryEntry, tab: {windowId}})-> + bypassCache = registryEntry.options.hard ? false + chrome.tabs.query {windowId}, (tabs) -> + position = do -> + for tab, index in tabs + return index if tab.id == tabId + tabs = [tabs[position...]..., tabs[...position]...] + count = Math.min count, tabs.length + chrome.tabs.reload tab.id, {bypassCache} for tab in tabs[...count] # Remove tabs before, after, or either side of the currently active tab removeTabsRelative = (direction, {tab: activeTab}) -> -- cgit v1.2.3