Add an option to close the current tab and select the tab to the left

Add an option to tabs.close to close the current tab
and select the tab to the left.

Bound to `D` by default, which replaces the tabs.close.right
command, which is rarely-used. [1]

The old `D` behavior has been moved to `gd`.

+ update the README and fix some lint errors

[1] https://tinyurl.com/y4mj7hjy
This commit is contained in:
chocolateboy 2019-07-28 05:35:07 +01:00
parent 3db11041c5
commit 6605d3ea99
10 changed files with 163 additions and 120 deletions

View file

@ -24,7 +24,8 @@ module.exports = {
"G": { "type": "scroll.bottom" },
"$": { "type": "scroll.end" },
"d": { "type": "tabs.close" },
"D": { "type": "tabs.close.right" },
"D": { "type": "tabs.close", "selectLeft": true },
"gd": { "type": "tabs.close.right" },
"!d": { "type": "tabs.close.force" },
"u": { "type": "tabs.reopen" },
"K": { "type": "tabs.prev", "count": 1 },

View file

@ -55,18 +55,32 @@ describe("tab test", () => {
await browser.windows.remove(win.id);
});
it('deletes tab by d', async () => {
it('deletes tab and selects right by d', async () => {
await browser.tabs.update(tabs[3].id, { active: true });
let body = await session.findElementByCSS('body');
await body.sendKeys('d');
let current = await browser.tabs.query({ windowId: win.id });
assert(current.length === tabs.length - 1);
assert(current[3].active);
assert(current[3].url === tabs[4].url);
});
it('deletes tabs to the right by D', async () => {
it('deletes tab and selects left by D', async () => {
await browser.tabs.update(tabs[3].id, { active: true });
let body = await session.findElementByCSS('body');
await body.sendKeys(Key.Shift, 'D');
let current = await browser.tabs.query({ windowId: win.id });
assert(current.length === tabs.length - 1);
assert(current[2].active);
assert(current[2].url === tabs[2].url);
});
it('deletes all tabs to the right by gD', async () => {
await browser.tabs.update(tabs[1].id, { active: true });
let body = await session.findElementByCSS('body');
await body.sendKeys(Key.Shift, 'd');
await body.sendKeys('g', Key.Shift, 'D');
let current = await browser.tabs.query({ windowId: win.id });
assert(current.length === 2);