[editor] Prevent an infinite loop when changing the snippet type
Changing the type would initialize the aceEditor binding which in turn would update the ace observable on the snippet causing the editor to initialize over and over again.
@@ -272,12 +272,17 @@ var EditorViewModel = (function() {
});
// Ace stuff
- self.ace = ko.observable(null);
- self.ace.subscribe(function () {
+ var aceEditor = null;
+
+ self.ace = function (newVal) {
+ if (newVal) {
+ aceEditor = newVal;
if (!vm.isPresentationMode()) {
- self.ace().focus();
+ aceEditor.focus();
}
- });
+ }
+ return aceEditor
+ };
self.errors = ko.observableArray([]);
self.aceErrorsHolder = ko.observableArray([]);
