diff --git a/plugins/c9.ide.editors/tab.js b/plugins/c9.ide.editors/tab.js index 11c18440..e841ebef 100644 --- a/plugins/c9.ide.editors/tab.js +++ b/plugins/c9.ide.editors/tab.js @@ -258,6 +258,8 @@ define(function(require, module, exports) { ); return; } + + var currentValue = plugin.document.value; editorType = type; amlTab.setAttribute("type", "editor::" + type); @@ -265,6 +267,11 @@ define(function(require, module, exports) { if (amlPane.getPage() == amlTab) { amlPane.activepage = -1; amlPane.set(amlTab); + + plugin.document.value = currentValue; + // TODO undo managers for different editors conflict + // however, resetting removes changed state + // plugin.document.undoManager.reset(); } callback(); diff --git a/plugins/c9.ide.ui/forms.js b/plugins/c9.ide.ui/forms.js index 471a9e4a..0ab3e6f8 100644 --- a/plugins/c9.ide.ui/forms.js +++ b/plugins/c9.ide.ui/forms.js @@ -456,20 +456,25 @@ define(function(require, exports, module) { case "dropdown": var dropdown = el.lastChild; - var data = item.items.map(function(item) { - return ""; - }).join(""); - if (data) { - setTimeout(function(){ - dropdown.$model.load("" + data + ""); - + if (item.items) { + var data = item.items.map(function(item) { + return ""; + }).join(""); + if (data) { setTimeout(function(){ - var value = item.value || dropdown.value; - dropdown.value = -999; - dropdown.setAttribute("value", value); + dropdown.$model.load("" + data + ""); + + setTimeout(function(){ + var value = item.value || dropdown.value; + dropdown.value = -999; + dropdown.setAttribute("value", value); + }); }); - }); + } + } + else if (item.value) { + dropdown.setAttribute("value", item.value); } break; default: