diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-12-03 22:42:33 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-12-09 23:09:34 +0900 |
commit | 781b26a961603141af9365bb85d582569331d52f (patch) | |
tree | ed14f2a8159a7333ed33d04b3fa2cbae9eb4d222 /src/background | |
parent | ca804b1b335df0e7a316d12ed9246beec55ff7f2 (diff) |
Fix select next/prev
Diffstat (limited to 'src/background')
3 files changed, 7 insertions, 13 deletions
diff --git a/src/background/operators/impls/SelectTabNextOperator.ts b/src/background/operators/impls/SelectTabNextOperator.ts index 37482fe..34d37ff 100644 --- a/src/background/operators/impls/SelectTabNextOperator.ts +++ b/src/background/operators/impls/SelectTabNextOperator.ts @@ -2,10 +2,7 @@ import Operator from "../Operator"; import TabPresenter from "../../presenters/TabPresenter"; export default class SelectTabNextOperator implements Operator { - constructor( - private readonly tabPresenter: TabPresenter, - private readonly count: number - ) {} + constructor(private readonly tabPresenter: TabPresenter) {} async run(): Promise<void> { const tabs = await this.tabPresenter.getAll(); @@ -16,7 +13,7 @@ export default class SelectTabNextOperator implements Operator { if (!tab) { return; } - const select = (tab.index + this.count) % tabs.length; + const select = (tab.index + 1) % tabs.length; return this.tabPresenter.select(tabs[select].id as number); } } diff --git a/src/background/operators/impls/SelectTabPrevOperator.ts b/src/background/operators/impls/SelectTabPrevOperator.ts index 93a0d6d..3776c1a 100644 --- a/src/background/operators/impls/SelectTabPrevOperator.ts +++ b/src/background/operators/impls/SelectTabPrevOperator.ts @@ -2,10 +2,7 @@ import Operator from "../Operator"; import TabPresenter from "../../presenters/TabPresenter"; export default class SelectTabPrevOperator implements Operator { - constructor( - private readonly tabPresenter: TabPresenter, - private readonly count: number - ) {} + constructor(private readonly tabPresenter: TabPresenter) {} async run(): Promise<void> { const tabs = await this.tabPresenter.getAll(); @@ -16,7 +13,7 @@ export default class SelectTabPrevOperator implements Operator { if (!tab) { return; } - const select = (tab.index - this.count + tabs.length) % tabs.length; + const select = (tab.index - 1 + tabs.length) % tabs.length; return this.tabPresenter.select(tabs[select].id as number); } } diff --git a/src/background/operators/impls/TabOperatorFactoryChain.ts b/src/background/operators/impls/TabOperatorFactoryChain.ts index b4cb401..edd3eaf 100644 --- a/src/background/operators/impls/TabOperatorFactoryChain.ts +++ b/src/background/operators/impls/TabOperatorFactoryChain.ts @@ -7,7 +7,7 @@ import CloseTabOperator from "./CloseTabOperator"; import CloseTabRightOperator from "./CloseTabRightOperator"; import ReopenTabOperator from "./ReopenTabOperator"; import SelectTabPrevOperator from "./SelectTabPrevOperator"; -import SelectTabNextOperator from "./SelectTabPrevOperator"; +import SelectTabNextOperator from "./SelectTabNextOperator"; import SelectFirstTabOperator from "./SelectFirstTabOperator"; import SelectLastTabOperator from "./SelectLastTabOperator"; import SelectPreviousSelectedTabOperator from "./SelectPreviousSelectedTabOperator"; @@ -39,9 +39,9 @@ export default class TabOperatorFactoryChain implements OperatorFactoryChain { case operations.TAB_REOPEN: return new ReopenTabOperator(this.tabPresenter); case operations.TAB_PREV: - return new SelectTabPrevOperator(this.tabPresenter, 1); + return new SelectTabPrevOperator(this.tabPresenter); case operations.TAB_NEXT: - return new SelectTabNextOperator(this.tabPresenter, 1); + return new SelectTabNextOperator(this.tabPresenter); case operations.TAB_FIRST: return new SelectFirstTabOperator(this.tabPresenter); case operations.TAB_LAST: |