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