Merge pull request #137 from alx741/tabs

Most recently used tab selector
jh-changes
Shin'ya Ueoka 7 years ago committed by GitHub
commit 423d17aeb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      README.md
  2. 2
      src/background/actions/operation.js
  3. 18
      src/background/tabs.js
  4. 1
      src/shared/operations.js
  5. 1
      src/shared/settings/default.js

@ -37,6 +37,7 @@ The default mappings are as follows:
- <kbd>u</kbd>: reopen close tab
- <kbd>K</kbd>, <kbd>J</kbd>: select prev or next tab
- <kbd>g0</kbd>, <kbd>g$</kbd>: select first or last tab
- <kbd>Ctrl</kbd>+<kbd>6</kbd>: select previous selected tab
- <kbd>r</kbd>: reload current tab
- <kbd>R</kbd>: reload current tab without cache
- <kbd>zp</kbd>: toggle pin/unpin current tab

@ -27,6 +27,8 @@ const exec = (operation, tab) => {
return tabs.selectFirstTab();
case operations.TAB_LAST:
return tabs.selectLastTab();
case operations.TAB_PREV_SEL:
return tabs.selectPrevSelTab();
case operations.TAB_RELOAD:
return tabs.reload(tab, operation.cache);
case operations.TAB_PIN:

@ -1,3 +1,13 @@
let prevSelTab = 1;
let currSelTab = 1;
browser.tabs.onActivated.addListener((activeInfo) => {
return browser.tabs.query({ currentWindow: true }).then(() => {
prevSelTab = currSelTab;
currSelTab = activeInfo.tabId;
});
});
const closeTab = (id) => {
return browser.tabs.remove(id);
};
@ -93,6 +103,10 @@ const selectLastTab = () => {
});
};
const selectPrevSelTab = () => {
return browser.tabs.update(prevSelTab, { active: true });
};
const reload = (current, cache) => {
return browser.tabs.reload(
current.id,
@ -117,6 +131,6 @@ const duplicate = (id) => {
export {
closeTab, reopenTab, selectAt, selectByKeyword, getCompletions,
selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, reload,
updateTabPinned, toggleTabPinned, duplicate
selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, selectPrevSelTab,
reload, updateTabPinned, toggleTabPinned, duplicate
};

@ -38,6 +38,7 @@ export default {
TAB_NEXT: 'tabs.next',
TAB_FIRST: 'tabs.first',
TAB_LAST: 'tabs.last',
TAB_PREV_SEL: 'tabs.prevsel',
TAB_RELOAD: 'tabs.reload',
TAB_PIN: 'tabs.pin',
TAB_UNPIN: 'tabs.unpin',

@ -28,6 +28,7 @@ export default {
"J": { "type": "tabs.next", "count": 1 },
"g0": { "type": "tabs.first" },
"g$": { "type": "tabs.last" },
"<C-6>": { "type": "tabs.prevsel" },
"r": { "type": "tabs.reload", "cache": false },
"R": { "type": "tabs.reload", "cache": true },
"zp": { "type": "tabs.pin.toggle" },