diff --git a/plugins/c9.ide.editors/tabmanager.js b/plugins/c9.ide.editors/tabmanager.js index 73b8d27d..2a974f48 100644 --- a/plugins/c9.ide.editors/tabmanager.js +++ b/plugins/c9.ide.editors/tabmanager.js @@ -498,8 +498,13 @@ define(function(require, module, exports) { state.pane = panes[i]; } if (!state.pane) { - throw new Error("Called open too early. Please wait until " - + "a pane is available. Use the ready event."); + if (isReady) { + state.pane = createPane({}); + container.appendChild(state.pane.aml); + } else { + throw new Error("Called open too early. Please wait until " + + "a pane is available. Use the ready event."); + } } } diff --git a/plugins/c9.ide.editors/tabmanager_test.js b/plugins/c9.ide.editors/tabmanager_test.js index 8c3d8b62..6f08e9f8 100644 --- a/plugins/c9.ide.editors/tabmanager_test.js +++ b/plugins/c9.ide.editors/tabmanager_test.js @@ -54,16 +54,6 @@ require(["lib/architect/architect", "lib/chai/chai"], }, "plugins/c9.fs/fs.cache.xml", - // Mock plugins - { - consumes: ["apf", "ui", "Plugin"], - provides: [ - "commands", "menus", "commands", "layout", "watcher", "proc", - "save", "anims", "clipboard", "dialog.alert", "auth.bootstrap", - "info", "dialog.error" - ], - setup: expect.html.mocked - }, { consumes: ["tabManager", "ui", "fs.cache", "fs"], provides: [], @@ -112,6 +102,21 @@ require(["lib/architect/architect", "lib/chai/chai"], var text; describe("open(), openFile(), openEditor() and reload()", function() { + it('should recover from state with no panes', function(done) { + var oldState = tabs.getState(); + tabs.setState({ + "nodes": [], + "type": "hsplitbox" + }, function() {}); + tabs.openEditor("timeview", function(err, tab) { + expect(tabs.getTabs()).length(1); + + expect(tabs.focussedTab) + .to.exist + .to.equal(tab); + tabs.setState(oldState, done); + }); + }); it('should open a pane from a path', function(done) { var vpath = "/file.txt"; tabs.openFile(vpath, function(err, tab) {