use cached textmode
This commit is contained in:
parent
62569d617d
commit
d4daa0f9d9
1 changed files with 9 additions and 6 deletions
|
|
@ -77,10 +77,7 @@ var EditSession = function(text, mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.selection = new Selection(this);
|
this.selection = new Selection(this);
|
||||||
if (mode)
|
this.setMode(mode);
|
||||||
this.setMode(mode);
|
|
||||||
else
|
|
||||||
this.setMode(new TextMode());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -508,6 +505,7 @@ var EditSession = function(text, mode) {
|
||||||
return callback(_self.$modes[mode]);
|
return callback(_self.$modes[mode]);
|
||||||
|
|
||||||
_self.$modes[mode] = new module.Mode();
|
_self.$modes[mode] = new module.Mode();
|
||||||
|
_self.$modes[mode].$id = mode;
|
||||||
_self._emit("loadmode", {
|
_self._emit("loadmode", {
|
||||||
name: mode,
|
name: mode,
|
||||||
mode: _self.$modes[mode]
|
mode: _self.$modes[mode]
|
||||||
|
|
@ -528,10 +526,9 @@ var EditSession = function(text, mode) {
|
||||||
this.$mode = null;
|
this.$mode = null;
|
||||||
this.$origMode = null;
|
this.$origMode = null;
|
||||||
this.setMode = function(mode) {
|
this.setMode = function(mode) {
|
||||||
this.$origMode = mode;
|
|
||||||
|
|
||||||
// load on demand
|
// load on demand
|
||||||
if (typeof mode === "string") {
|
if (typeof mode === "string") {
|
||||||
|
this.$origMode = mode;
|
||||||
var _self = this;
|
var _self = this;
|
||||||
this._loadMode(mode, function(module) {
|
this._loadMode(mode, function(module) {
|
||||||
if (_self.$origMode !== mode)
|
if (_self.$origMode !== mode)
|
||||||
|
|
@ -540,6 +537,12 @@ var EditSession = function(text, mode) {
|
||||||
_self.setMode(module);
|
_self.setMode(module);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
} else if (mode == null) {
|
||||||
|
mode = "ace/mode/text"
|
||||||
|
this.$origMode = mode;
|
||||||
|
this.$modes[mode] = this.$modes[mode] || (new TextMode());
|
||||||
|
this.setMode(this.$modes[mode]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.$mode === mode) return;
|
if (this.$mode === mode) return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue