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") }
This commit is contained in:
parent
c57089224e
commit
f65c068c67
6 changed files with 21 additions and 8 deletions
|
@ -24,7 +24,7 @@ module.exports = {
|
||||||
"G": { "type": "scroll.bottom" },
|
"G": { "type": "scroll.bottom" },
|
||||||
"$": { "type": "scroll.end" },
|
"$": { "type": "scroll.end" },
|
||||||
"d": { "type": "tabs.close" },
|
"d": { "type": "tabs.close" },
|
||||||
"D": { "type": "tabs.close", "selectLeft": true },
|
"D": { "type": "tabs.close", "select": "left" },
|
||||||
"x$": { "type": "tabs.close.right" },
|
"x$": { "type": "tabs.close.right" },
|
||||||
"!d": { "type": "tabs.close.force" },
|
"!d": { "type": "tabs.close.force" },
|
||||||
"u": { "type": "tabs.reopen" },
|
"u": { "type": "tabs.reopen" },
|
||||||
|
|
|
@ -32,7 +32,7 @@ export default class OperationController {
|
||||||
doOperation(operation: operations.Operation): Promise<any> {
|
doOperation(operation: operations.Operation): Promise<any> {
|
||||||
switch (operation.type) {
|
switch (operation.type) {
|
||||||
case operations.TAB_CLOSE:
|
case operations.TAB_CLOSE:
|
||||||
return this.tabUseCase.close(false, operation.selectLeft);
|
return this.tabUseCase.close(false, operation.select === 'left');
|
||||||
case operations.TAB_CLOSE_RIGHT:
|
case operations.TAB_CLOSE_RIGHT:
|
||||||
return this.tabUseCase.closeRight();
|
return this.tabUseCase.closeRight();
|
||||||
case operations.TAB_CLOSE_FORCE:
|
case operations.TAB_CLOSE_FORCE:
|
||||||
|
|
|
@ -18,7 +18,7 @@ const fields = [
|
||||||
['mark.set.prefix', 'Set mark at current position'],
|
['mark.set.prefix', 'Set mark at current position'],
|
||||||
['mark.jump.prefix', 'Jump to the mark'],
|
['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.close.right', 'Close all tabs to the right'],
|
||||||
['tabs.reopen', 'Reopen closed tab'],
|
['tabs.reopen', 'Reopen closed tab'],
|
||||||
['tabs.next', 'Select next tab'],
|
['tabs.next', 'Select next tab'],
|
||||||
|
|
|
@ -353,7 +353,7 @@ export const DefaultSettingData: SettingData = SettingData.valueOf({
|
||||||
"G": { "type": "scroll.bottom" },
|
"G": { "type": "scroll.bottom" },
|
||||||
"$": { "type": "scroll.end" },
|
"$": { "type": "scroll.end" },
|
||||||
"d": { "type": "tabs.close" },
|
"d": { "type": "tabs.close" },
|
||||||
"D": { "type": "tabs.close", "selectLeft": true },
|
"D": { "type": "tabs.close", "select": "left" },
|
||||||
"x$": { "type": "tabs.close.right" },
|
"x$": { "type": "tabs.close.right" },
|
||||||
"!d": { "type": "tabs.close.force" },
|
"!d": { "type": "tabs.close.force" },
|
||||||
"u": { "type": "tabs.reopen" },
|
"u": { "type": "tabs.reopen" },
|
||||||
|
|
|
@ -146,7 +146,7 @@ export const DefaultSetting: Settings = {
|
||||||
'G': { 'type': 'scroll.bottom' },
|
'G': { 'type': 'scroll.bottom' },
|
||||||
'$': { 'type': 'scroll.end' },
|
'$': { 'type': 'scroll.end' },
|
||||||
'd': { 'type': 'tabs.close' },
|
'd': { 'type': 'tabs.close' },
|
||||||
'D': { 'type': 'tabs.close', 'selectLeft': true },
|
'D': { 'type': 'tabs.close', 'select': 'left' },
|
||||||
'x$': { 'type': 'tabs.close.right' },
|
'x$': { 'type': 'tabs.close.right' },
|
||||||
'!d': { 'type': 'tabs.close.force' },
|
'!d': { 'type': 'tabs.close.force' },
|
||||||
'u': { 'type': 'tabs.reopen' },
|
'u': { 'type': 'tabs.reopen' },
|
||||||
|
|
|
@ -201,7 +201,7 @@ export interface PageHomeOperation {
|
||||||
|
|
||||||
export interface TabCloseOperation {
|
export interface TabCloseOperation {
|
||||||
type: typeof TAB_CLOSE;
|
type: typeof TAB_CLOSE;
|
||||||
selectLeft?: boolean;
|
select?: 'left' | 'right';
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TabCloseForceOperation {
|
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) => {
|
const assertRequiredNumber = (obj: any, name: string) => {
|
||||||
if (!Object.prototype.hasOwnProperty.call(obj, name) ||
|
if (!Object.prototype.hasOwnProperty.call(obj, name) ||
|
||||||
typeof obj[name] !== 'number') {
|
typeof obj[name] !== 'number') {
|
||||||
|
@ -418,10 +431,10 @@ export const valueOf = (o: any): Operation => {
|
||||||
newTab: Boolean(typeof o.newTab === undefined ? false : o.newTab),
|
newTab: Boolean(typeof o.newTab === undefined ? false : o.newTab),
|
||||||
};
|
};
|
||||||
case TAB_CLOSE:
|
case TAB_CLOSE:
|
||||||
assertOptionalBoolean(o, 'selectLeft');
|
assertOptionalString(o, 'select', ['left', 'right']);
|
||||||
return {
|
return {
|
||||||
type: TAB_CLOSE,
|
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:
|
case TAB_RELOAD:
|
||||||
assertOptionalBoolean(o, 'cache');
|
assertOptionalBoolean(o, 'cache');
|
||||||
|
|
Reference in a new issue