Skip to content

Commit 201210f

Browse files
committed
update highlighting when mode is changed
1 parent 30445fd commit 201210f

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

tool/mode_creator.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,43 @@ var editor2 = window.editor2 = splitEditor.editor1;
2323
new TokenTooltip(editor2);
2424

2525
var timeout = null;
26-
schedule = function() {
27-
if(timeout != null) {
26+
var schedule = function() {
27+
if (timeout != null) {
2828
clearTimeout(timeout);
2929
}
3030
timeout = setTimeout(run, 800);
3131
};
3232

3333

34-
setAutorunEnabled = function(val) {
34+
var setAutorunEnabled = function(val) {
3535
if (val)
3636
editor1.on('change', schedule);
3737
else
3838
editor1.removeEventListener('change', schedule);
39-
}
39+
};
4040

4141
util.bindCheckbox("autorunEl", setAutorunEnabled);
4242

4343

44-
docEl = document.getElementById("doc");
44+
var docEl = document.getElementById("doc");
4545
util.fillDropdown(docEl, doclist.docs);
4646
util.bindDropdown("doc", function(value) {
4747
doclist.loadDoc(value, function(session) {
4848
if (session) {
4949
editor2.setSession(session);
5050
}
51-
})
51+
});
5252
});
5353

54-
modeEl = document.getElementById("modeEl");
54+
var modeEl = document.getElementById("modeEl");
5555
util.fillDropdown(modeEl, modelist.modes);
5656
var modeSessions = {};
5757
util.bindDropdown(modeEl, function(value) {
58-
if (modeSessions[value])
58+
if (modeSessions[value]) {
5959
editor1.setSession(modeSessions[value]);
60+
schedule();
61+
return;
62+
}
6063
var hp = "./lib/ace/mode/" + value + "_highlight_rules.js";
6164
net.get(hp, function(text) {
6265
text = util.stripLeadingComments(text);
@@ -67,6 +70,7 @@ util.bindDropdown(modeEl, function(value) {
6770
session.setMode("ace/mode/javascript");
6871

6972
editor1.setSession(modeSessions[value]);
73+
schedule();
7074
});
7175
});
7276

0 commit comments

Comments
 (0)