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