setting mode to same string shouldn't reset it

This commit is contained in:
nightwing 2012-04-29 23:33:37 +04:00
commit 51f8f87a98

View file

@ -524,14 +524,17 @@ var EditSession = function(text, mode) {
};
this.$mode = null;
this.$origMode = null;
this.$modeId = null;
this.setMode = function(mode) {
// load on demand
if (typeof mode === "string") {
this.$origMode = mode;
if (this.$modeId == mode)
return;
this.$modeId = mode;
var _self = this;
this._loadMode(mode, function(module) {
if (_self.$origMode !== mode)
if (_self.$modeId !== mode)
return;
_self.setMode(module);
@ -539,7 +542,7 @@ var EditSession = function(text, mode) {
return;
} else if (mode == null) {
mode = "ace/mode/text"
this.$origMode = mode;
this.$modeId = mode;
this.$modes[mode] = this.$modes[mode] || (new TextMode());
this.setMode(this.$modes[mode]);
return;
@ -547,7 +550,7 @@ var EditSession = function(text, mode) {
if (this.$mode === mode) return;
this.$mode = mode;
this.$modeId = mode.$id;
this.$stopWorker();