aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--e2e/settings.js2
-rw-r--r--src/background/controllers/OperationController.ts2
-rw-r--r--src/settings/keymaps.ts2
-rw-r--r--src/shared/SettingData.ts2
-rw-r--r--src/shared/Settings.ts2
-rw-r--r--src/shared/operations.ts19
6 files changed, 21 insertions, 8 deletions
diff --git a/e2e/settings.js b/e2e/settings.js
index b69e3e7..e78add0 100644
--- a/e2e/settings.js
+++ b/e2e/settings.js
@@ -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" },
diff --git a/src/background/controllers/OperationController.ts b/src/background/controllers/OperationController.ts
index 9480ed5..7a10ad6 100644
--- a/src/background/controllers/OperationController.ts
+++ b/src/background/controllers/OperationController.ts
@@ -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:
diff --git a/src/settings/keymaps.ts b/src/settings/keymaps.ts
index b9a08e6..24ba1a5 100644
--- a/src/settings/keymaps.ts
+++ b/src/settings/keymaps.ts
@@ -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'],
diff --git a/src/shared/SettingData.ts b/src/shared/SettingData.ts
index e6434a2..14a7d35 100644
--- a/src/shared/SettingData.ts
+++ b/src/shared/SettingData.ts
@@ -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" },
diff --git a/src/shared/Settings.ts b/src/shared/Settings.ts
index 19101c1..2a392df 100644
--- a/src/shared/Settings.ts
+++ b/src/shared/Settings.ts
@@ -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' },
diff --git a/src/shared/operations.ts b/src/shared/operations.ts
index f657db1..2df2e67 100644
--- a/src/shared/operations.ts
+++ b/src/shared/operations.ts
@@ -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');