From a52b93b35d7a63e33c6743b162edc951e082e42e Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Wed, 28 Oct 2015 15:03:15 -0700 Subject: [PATCH] Fixes c9/core+110 always use close() when unloading tabs --- plugins/c9.ide.editors/tab.js | 9 +++++++++ plugins/c9.ide.editors/tabmanager.js | 10 +++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/plugins/c9.ide.editors/tab.js b/plugins/c9.ide.editors/tab.js index e841ebef..dfb022b2 100644 --- a/plugins/c9.ide.editors/tab.js +++ b/plugins/c9.ide.editors/tab.js @@ -289,6 +289,15 @@ define(function(require, module, exports) { load(); }); + plugin.on("beforeUnload", function(){ + if (!plugin.meta.$closing) { + plugin.document.meta.$ignoreSave = true; + close(); + delete plugin.document.meta.$ignoreSave; + return false; + } + }); + plugin.on("unload", function(e) { closed = true; diff --git a/plugins/c9.ide.editors/tabmanager.js b/plugins/c9.ide.editors/tabmanager.js index 21cad3e8..fd210a5a 100644 --- a/plugins/c9.ide.editors/tabmanager.js +++ b/plugins/c9.ide.editors/tabmanager.js @@ -132,11 +132,8 @@ define(function(require, module, exports) { function removeTab(e) { if (!e.error) { var tab = findTab(e.path); - if (tab) { - tab.document.meta.$ignoreSave = true; - tab.close(); - delete tab.document.meta.$ignoreSave; - } + if (tab) + tab.unload(); } } fs.on("afterUnlink", removeTab); @@ -145,9 +142,8 @@ define(function(require, module, exports) { var path = e.path; Object.keys(tabs).forEach(function(id) { var tab = tabs[id]; - if (tab.path && tab.path.indexOf(path) === 0) { + if (tab.path && tab.path.indexOf(path) === 0) tab.unload(); - } }); }); // Close a pane when it doesn't open