From 6c632543c119d9d432d432e51af5136107e4cf33 Mon Sep 17 00:00:00 2001 From: Lennart kats Date: Fri, 22 Jan 2016 13:41:56 +0000 Subject: [PATCH 1/2] Make callback optional --- plugins/c9.ide.editors/tabmanager.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/c9.ide.editors/tabmanager.js b/plugins/c9.ide.editors/tabmanager.js index df0aa20c..da270a71 100644 --- a/plugins/c9.ide.editors/tabmanager.js +++ b/plugins/c9.ide.editors/tabmanager.js @@ -990,6 +990,8 @@ define(function(require, module, exports) { } function open(options, callback) { + callback = callback || function() {}; + var path = options.path = util.normalizePath(options.path); var type = options.editorType; var editor; @@ -1889,7 +1891,7 @@ define(function(require, module, exports) { * @param {String} [options.value] The contents of the file * @param {String} [options.title] The title of the tab * @param {String} [options.tooltip] The tooltip at the button of the tab - * @param {Function} callback + * @param {Function} [callback] * @param {Error} callback.err An error that might * occur during the load of the file contents. * @param {Tab} callback.tab The created tab. From b52cca8bc3710eef5d02ada70810f53a1d548912 Mon Sep 17 00:00:00 2001 From: Lennart kats Date: Fri, 22 Jan 2016 13:41:24 +0000 Subject: [PATCH 2/2] Set state before firing event Otherwise e.g. preview won't work yet in tabs.on("ready") --- plugins/c9.ide.editors/tabmanager.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/c9.ide.editors/tabmanager.js b/plugins/c9.ide.editors/tabmanager.js index da270a71..61b4462f 100644 --- a/plugins/c9.ide.editors/tabmanager.js +++ b/plugins/c9.ide.editors/tabmanager.js @@ -220,13 +220,14 @@ define(function(require, module, exports) { } setTimeout(function() { - // Only set the state if we're not testing something else - if (options.testing != 2 && !isReady) { + var wasReady = isReady; + isReady = true; + if (options.testing != 2 && !wasReady) { + // Only fire if we're not testing something else setState(state, !isReady, function(){ emit.sticky("ready"); }); } - isReady = true; showTabs = settings.getBool("user/tabs/@show"); toggleButtons(showTabs);