You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/ace/edit_session.js
+10-5Lines changed: 10 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -865,11 +865,12 @@ var EditSession = function(text, mode) {
865
865
/**
866
866
* Sets a new text mode for the `EditSession`. This method also emits the `'changeMode'` event. If a [[BackgroundTokenizer `BackgroundTokenizer`]] is set, the `'tokenizerUpdate'` event is also emitted.
867
867
* @param {TextMode} mode Set a new text mode
868
+
* @param {cb} optional callback
868
869
*
869
870
**/
870
871
this.$mode=null;
871
872
this.$modeId=null;
872
-
this.setMode=function(mode){
873
+
this.setMode=function(mode,cb){
873
874
if(mode&&typeofmode==="object"){
874
875
if(mode.getTokenizer)
875
876
returnthis.$onChangeMode(mode);
@@ -890,7 +891,7 @@ var EditSession = function(text, mode) {
890
891
this.$modeId=path;
891
892
config.loadModule(["mode",path],function(m){
892
893
if(this.$modeId!==path)
893
-
return;
894
+
returncb&&cb();
894
895
if(this.$modes[path]&&!options)
895
896
returnthis.$onChangeMode(this.$modes[path]);
896
897
if(m&&m.Mode){
@@ -899,7 +900,8 @@ var EditSession = function(text, mode) {
899
900
this.$modes[path]=m;
900
901
m.$id=path;
901
902
}
902
-
this.$onChangeMode(m)
903
+
this.$onChangeMode(m);
904
+
cb&&cb(this.mode);
903
905
}
904
906
}.bind(this));
905
907
@@ -909,7 +911,11 @@ var EditSession = function(text, mode) {
909
911
};
910
912
911
913
this.$onChangeMode=function(mode,$isPlaceholder){
912
-
if(this.$mode===mode)return;
914
+
if(!$isPlaceholder)
915
+
this.$modeId=mode.$id;
916
+
if(this.$mode===mode)
917
+
return;
918
+
913
919
this.$mode=mode;
914
920
915
921
this.$stopWorker();
@@ -941,7 +947,6 @@ var EditSession = function(text, mode) {
0 commit comments