new function to switchToActive tab

pull/3094/head
LianaHus 5 years ago
parent 8c99b1dcae
commit bec946ea0b
  1. 4
      src/app/files/fileManager.js
  2. 10
      src/app/panels/tab-proxy.js

@ -102,9 +102,7 @@ class FileManager extends Plugin {
closeFile (name) {
delete this.openedFiles[name]
if (Object.keys(this.openedFiles).length) {
this.switchFile(Object.keys(this.openedFiles)[0])
} else {
if (!Object.keys(this.openedFiles).length) {
this.editor.displayEmptyReadOnlySession()
this._deps.config.set('currentFile', '')
this.events.emit('noFileSelected')

@ -20,7 +20,6 @@ export class TabProxy {
fileManager.events.on('fileClosed', (name) => {
this.removeTab(name)
this.switchPreviousTab()
})
fileManager.events.on('currentFileChanged', (file) => {
@ -105,11 +104,19 @@ export class TabProxy {
const handlers = Object.keys(this._handlers)
let i = handlers.indexOf(active)
if (i >= 0) {
i = handlers[i - 1] ? i - 1 : handlers.length - 1
this.switchTab(handlers[i])
}
}
}
switchToActiveTab () {
const active = this._view.filetabs.active
if (active && this._handlers[active]) {
this.switchTab(active)
}
}
showTab (name) {
this._view.filetabs.activateTab(name)
}
@ -133,6 +140,7 @@ export class TabProxy {
removeTab (name) {
this._view.filetabs.removeTab(name)
delete this._handlers[name]
this.switchToActiveTab ()
}
addHandler (type, fn) {

Loading…
Cancel
Save