From db86150832b5090f0a44dc88c2d62bedebc89551 Mon Sep 17 00:00:00 2001 From: Chris Kaczor Date: Mon, 14 Oct 2019 17:14:23 -0400 Subject: [PATCH] Add option to disable tab restore on startup --- terminus-core/src/services/app.service.ts | 29 ++++++++++++------- .../terminalSettingsTab.component.pug | 9 ++++++ terminus-terminal/src/config.ts | 1 + 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/terminus-core/src/services/app.service.ts b/terminus-core/src/services/app.service.ts index 7e6ea370..57722fce 100644 --- a/terminus-core/src/services/app.service.ts +++ b/terminus-core/src/services/app.service.ts @@ -71,20 +71,29 @@ export class AppService { private tabsService: TabsService, ) { if (hostApp.getWindow().id === 1) { - this.tabRecovery.recoverTabs().then(tabs => { - for (const tab of tabs) { - this.openNewTabRaw(tab.type, tab.options) - } - this.tabsChanged$.subscribe(() => { - tabRecovery.saveTabs(this.tabs) + if (config.store.terminal.recoverTabs) { + this.tabRecovery.recoverTabs().then(tabs => { + for (const tab of tabs) { + this.openNewTabRaw(tab.type, tab.options) + } + this.startTabStorage() }) - setInterval(() => { - tabRecovery.saveTabs(this.tabs) - }, 30000) - }) + } else { + /** Continue to store the tabs even if the setting is currently off */ + this.startTabStorage() + } } } + startTabStorage() { + this.tabsChanged$.subscribe(() => { + this.tabRecovery.saveTabs(this.tabs) + }) + setInterval(() => { + this.tabRecovery.saveTabs(this.tabs) + }, 30000) + } + addTabRaw (tab: BaseTabComponent) { this.tabs.push(tab) this.selectTab(tab) diff --git a/terminus-terminal/src/components/terminalSettingsTab.component.pug b/terminus-terminal/src/components/terminalSettingsTab.component.pug index bee79326..3e4fd1e4 100644 --- a/terminus-terminal/src/components/terminalSettingsTab.component.pug +++ b/terminus-terminal/src/components/terminalSettingsTab.component.pug @@ -66,6 +66,15 @@ h3.mb-3 Terminal (ngModelChange)='config.save()', ) +.form-line + .header + .title Restore terminal tabs on app start + + toggle( + [(ngModel)]='config.store.terminal.recoverTabs', + (ngModelChange)='config.save()', + ) + .form-line .header .title Bracketed paste (requires shell support) diff --git a/terminus-terminal/src/config.ts b/terminus-terminal/src/config.ts index 8bf66dd0..6ff19b2e 100644 --- a/terminus-terminal/src/config.ts +++ b/terminus-terminal/src/config.ts @@ -59,6 +59,7 @@ export class TerminalConfigProvider extends ConfigProvider { environment: {}, profiles: [], useConPTY: true, + recoverTabs: true, }, }