diff --git a/tabby-core/src/services/app.service.ts b/tabby-core/src/services/app.service.ts index a49630e9..5a464092 100644 --- a/tabby-core/src/services/app.service.ts +++ b/tabby-core/src/services/app.service.ts @@ -144,7 +144,7 @@ export class AppService { } removeTab (tab: BaseTabComponent): void { - const newIndex = Math.max(0, this.tabs.indexOf(tab) - 1) + const newIndex = Math.min(this.tabs.length - 2, this.tabs.indexOf(tab)) this.tabs = this.tabs.filter((x) => x !== tab) if (tab === this._activeTab) { this.selectTab(this.tabs[newIndex])