tabs.close: rename selectLeft (boolean) -> select ("left" | "right")

before:

    {
        "type": "tabs.close",
        "selectLeft": true | false // (default: false)
    }

after:

    {
        "type": "tabs.close",
        "select": "left" | "right" // (default: "right")
    }
jh-changes
chocolateboy 5 years ago
parent c57089224e
commit f65c068c67
  1. 2
      e2e/settings.js
  2. 2
      src/background/controllers/OperationController.ts
  3. 2
      src/settings/keymaps.ts
  4. 2
      src/shared/SettingData.ts
  5. 2
      src/shared/Settings.ts
  6. 19
      src/shared/operations.ts

@ -24,7 +24,7 @@ module.exports = {
"G": { "type": "scroll.bottom" },
"$": { "type": "scroll.end" },
"d": { "type": "tabs.close" },
"D": { "type": "tabs.close", "selectLeft": true },
"D": { "type": "tabs.close", "select": "left" },
"x$": { "type": "tabs.close.right" },
"!d": { "type": "tabs.close.force" },
"u": { "type": "tabs.reopen" },

@ -32,7 +32,7 @@ export default class OperationController {
doOperation(operation: operations.Operation): Promise<any> {
switch (operation.type) {
case operations.TAB_CLOSE:
return this.tabUseCase.close(false, operation.selectLeft);
return this.tabUseCase.close(false, operation.select === 'left');
case operations.TAB_CLOSE_RIGHT:
return this.tabUseCase.closeRight();
case operations.TAB_CLOSE_FORCE:

@ -18,7 +18,7 @@ const fields = [
['mark.set.prefix', 'Set mark at current position'],
['mark.jump.prefix', 'Jump to the mark'],
], [
['tabs.close?{"selectLeft":false}', 'Close a tab'],
['tabs.close?{"select":"right"}', 'Close a tab'],
['tabs.close.right', 'Close all tabs to the right'],
['tabs.reopen', 'Reopen closed tab'],
['tabs.next', 'Select next tab'],

@ -353,7 +353,7 @@ export const DefaultSettingData: SettingData = SettingData.valueOf({
"G": { "type": "scroll.bottom" },
"$": { "type": "scroll.end" },
"d": { "type": "tabs.close" },
"D": { "type": "tabs.close", "selectLeft": true },
"D": { "type": "tabs.close", "select": "left" },
"x$": { "type": "tabs.close.right" },
"!d": { "type": "tabs.close.force" },
"u": { "type": "tabs.reopen" },

@ -146,7 +146,7 @@ export const DefaultSetting: Settings = {
'G': { 'type': 'scroll.bottom' },
'$': { 'type': 'scroll.end' },
'd': { 'type': 'tabs.close' },
'D': { 'type': 'tabs.close', 'selectLeft': true },
'D': { 'type': 'tabs.close', 'select': 'left' },
'x$': { 'type': 'tabs.close.right' },
'!d': { 'type': 'tabs.close.force' },
'u': { 'type': 'tabs.reopen' },

@ -201,7 +201,7 @@ export interface PageHomeOperation {
export interface TabCloseOperation {
type: typeof TAB_CLOSE;
selectLeft?: boolean;
select?: 'left' | 'right';
}
export interface TabCloseForceOperation {
@ -372,6 +372,19 @@ const assertOptionalBoolean = (obj: any, name: string) => {
}
};
const assertOptionalString = (obj: any, name: string, values?: string[]) => {
if (Object.prototype.hasOwnProperty.call(obj, name)) {
let value = obj[name];
if (typeof value !== 'string') {
throw new TypeError(`Not a string parameter: '${name}'`);
}
if (values && values.length && values.indexOf(value) === -1) {
// eslint-disable-next-line max-len
throw new TypeError(`Invalid parameter for '${name}': '${value}'`);
}
}
};
const assertRequiredNumber = (obj: any, name: string) => {
if (!Object.prototype.hasOwnProperty.call(obj, name) ||
typeof obj[name] !== 'number') {
@ -418,10 +431,10 @@ export const valueOf = (o: any): Operation => {
newTab: Boolean(typeof o.newTab === undefined ? false : o.newTab),
};
case TAB_CLOSE:
assertOptionalBoolean(o, 'selectLeft');
assertOptionalString(o, 'select', ['left', 'right']);
return {
type: TAB_CLOSE,
selectLeft: Boolean(typeof o.selectLeft === undefined ? false : o.selectLeft), // eslint-disable-line max-len
select: (typeof o.select === undefined ? 'right' : o.select),
};
case TAB_RELOAD:
assertOptionalBoolean(o, 'cache');