From f57a3c41e78f3931b2eddfa8b55c8dbfa15eb480 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Tue, 16 Jul 2019 13:08:33 +0200 Subject: [PATCH] new function to switchToActive tab --- src/app/files/fileManager.js | 4 +--- src/app/panels/tab-proxy.js | 10 +++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index a50cd38dfb..b397cfde35 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.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') diff --git a/src/app/panels/tab-proxy.js b/src/app/panels/tab-proxy.js index 99b40deb7a..c58c73dc26 100644 --- a/src/app/panels/tab-proxy.js +++ b/src/app/panels/tab-proxy.js @@ -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) {