mirror of
https://github.com/Eugeny/tabby.git
synced 2025-09-24 17:16:03 +00:00
hotkey to reopen last tab (fixes #2239)
This commit is contained in:
@@ -114,6 +114,9 @@ export class AppRootComponent {
|
|||||||
if (hotkey === 'move-tab-right') {
|
if (hotkey === 'move-tab-right') {
|
||||||
this.app.moveSelectedTabRight()
|
this.app.moveSelectedTabRight()
|
||||||
}
|
}
|
||||||
|
if (hotkey === 'reopen-tab') {
|
||||||
|
this.app.reopenLastTab()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (hotkey === 'toggle-fullscreen') {
|
if (hotkey === 'toggle-fullscreen') {
|
||||||
this.hostApp.toggleFullscreen()
|
this.hostApp.toggleFullscreen()
|
||||||
|
@@ -7,6 +7,8 @@ hotkeys:
|
|||||||
- 'F11'
|
- 'F11'
|
||||||
close-tab:
|
close-tab:
|
||||||
- 'Ctrl-Shift-W'
|
- 'Ctrl-Shift-W'
|
||||||
|
reopen-tab:
|
||||||
|
- 'Ctrl-Shift-T'
|
||||||
toggle-last-tab: []
|
toggle-last-tab: []
|
||||||
rename-tab:
|
rename-tab:
|
||||||
- 'Ctrl-Shift-R'
|
- 'Ctrl-Shift-R'
|
||||||
|
@@ -7,6 +7,8 @@ hotkeys:
|
|||||||
- 'Ctrl+⌘+F'
|
- 'Ctrl+⌘+F'
|
||||||
close-tab:
|
close-tab:
|
||||||
- '⌘-W'
|
- '⌘-W'
|
||||||
|
reopen-tab:
|
||||||
|
- '⌘-Shift-T'
|
||||||
toggle-last-tab: []
|
toggle-last-tab: []
|
||||||
rename-tab:
|
rename-tab:
|
||||||
- '⌘-R'
|
- '⌘-R'
|
||||||
|
@@ -8,6 +8,8 @@ hotkeys:
|
|||||||
- 'Alt-Enter'
|
- 'Alt-Enter'
|
||||||
close-tab:
|
close-tab:
|
||||||
- 'Ctrl-Shift-W'
|
- 'Ctrl-Shift-W'
|
||||||
|
reopen-tab:
|
||||||
|
- 'Ctrl-Shift-T'
|
||||||
toggle-last-tab: []
|
toggle-last-tab: []
|
||||||
rename-tab:
|
rename-tab:
|
||||||
- 'Ctrl-Shift-R'
|
- 'Ctrl-Shift-R'
|
||||||
|
@@ -25,6 +25,10 @@ export class AppHotkeyProvider extends HotkeyProvider {
|
|||||||
id: 'close-tab',
|
id: 'close-tab',
|
||||||
name: 'Close tab',
|
name: 'Close tab',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'reopen-tab',
|
||||||
|
name: 'Reopen last tab',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'toggle-last-tab',
|
id: 'toggle-last-tab',
|
||||||
name: 'Toggle last tab',
|
name: 'Toggle last tab',
|
||||||
|
@@ -8,6 +8,7 @@ import { BaseTabComponent } from '../components/baseTab.component'
|
|||||||
import { SplitTabComponent } from '../components/splitTab.component'
|
import { SplitTabComponent } from '../components/splitTab.component'
|
||||||
import { SelectorModalComponent } from '../components/selectorModal.component'
|
import { SelectorModalComponent } from '../components/selectorModal.component'
|
||||||
import { SelectorOption } from '../api/selector'
|
import { SelectorOption } from '../api/selector'
|
||||||
|
import { RecoveryToken } from '../api/tabRecovery'
|
||||||
|
|
||||||
import { ConfigService } from './config.service'
|
import { ConfigService } from './config.service'
|
||||||
import { HostAppService } from './hostApp.service'
|
import { HostAppService } from './hostApp.service'
|
||||||
@@ -49,6 +50,7 @@ export class AppService {
|
|||||||
|
|
||||||
private lastTabIndex = 0
|
private lastTabIndex = 0
|
||||||
private _activeTab: BaseTabComponent
|
private _activeTab: BaseTabComponent
|
||||||
|
private closedTabsStack: RecoveryToken[] = []
|
||||||
|
|
||||||
private activeTabChange = new Subject<BaseTabComponent>()
|
private activeTabChange = new Subject<BaseTabComponent>()
|
||||||
private tabsChanged = new Subject<void>()
|
private tabsChanged = new Subject<void>()
|
||||||
@@ -98,6 +100,13 @@ export class AppService {
|
|||||||
hostApp.windowFocused$.subscribe(() => {
|
hostApp.windowFocused$.subscribe(() => {
|
||||||
this._activeTab?.emitFocused()
|
this._activeTab?.emitFocused()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.tabClosed$.subscribe(async tab => {
|
||||||
|
const token = await tab.getRecoveryToken()
|
||||||
|
if (token) {
|
||||||
|
this.closedTabsStack.push(token)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
addTabRaw (tab: BaseTabComponent, index: number|null = null): void {
|
addTabRaw (tab: BaseTabComponent, index: number|null = null): void {
|
||||||
@@ -161,6 +170,23 @@ export class AppService {
|
|||||||
return tab
|
return tab
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async reopenLastTab (): Promise<BaseTabComponent|null> {
|
||||||
|
const token = this.closedTabsStack.pop()
|
||||||
|
if (token) {
|
||||||
|
const recoveredTab = await this.tabRecovery.recoverTab(token)
|
||||||
|
if (recoveredTab) {
|
||||||
|
const tab = this.tabsService.create(recoveredTab.type, recoveredTab.options)
|
||||||
|
if (this.activeTab) {
|
||||||
|
this.addTabRaw(tab, this.tabs.indexOf(this.activeTab) + 1)
|
||||||
|
} else {
|
||||||
|
this.addTabRaw(tab)
|
||||||
|
}
|
||||||
|
return tab
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
selectTab (tab: BaseTabComponent): void {
|
selectTab (tab: BaseTabComponent): void {
|
||||||
if (this._activeTab === tab) {
|
if (this._activeTab === tab) {
|
||||||
this._activeTab.emitFocused()
|
this._activeTab.emitFocused()
|
||||||
|
Reference in New Issue
Block a user