##// END OF EJS Templates
handling explicitly provided modes from kernelspec.language_info
Nicholas Bollweg (Nick) -
Show More
@@ -612,21 +612,19 b' define(['
612 612 * require and callback with the resolveable mode string: mime or
613 613 * custom name
614 614 */
615 if (typeof mode != "string") mode = mode.name;
616 615
617 if (CodeMirror.modes.hasOwnProperty(mode)) {
616 var modename = (typeof mode == "string") ? mode :
617 mode.mode || mode.name;
618
619 if (CodeMirror.modes.hasOwnProperty(modename)) {
618 620 callback(mode);
619 621 return;
620 622 }
621 623
622 var info = CodeMirror.findModeByName(mode) ||
623 CodeMirror.findModeByExtension(mode.split(".").slice(-1)) ||
624 CodeMirror.findModeByMIME(mode);
625
626 if(!info){
627 errback && errback();
628 return;
629 }
624 var info = (mode && mode.mode && mode.mime && mode) ||
625 CodeMirror.findModeByName(modename) ||
626 CodeMirror.findModeByExtension(modename.split(".").slice(-1)) ||
627 CodeMirror.findModeByMIME(modename);
630 628
631 629 require([
632 630 // might want to use CodeMirror.modeURL here
@@ -1585,10 +1585,9 b' define(['
1585 1585 }
1586 1586 this.codemirror_mode = newmode;
1587 1587 codecell.CodeCell.options_default.cm_config.mode = newmode;
1588 var modename = newmode.mode || newmode.name || newmode;
1589 1588
1590 1589 var that = this;
1591 utils.requireCodeMirrorMode(modename, function () {
1590 utils.requireCodeMirrorMode(newmode, function () {
1592 1591 that.get_cells().map(function(cell, i) {
1593 1592 if (cell.cell_type === 'code'){
1594 1593 cell.code_mirror.setOption('mode', newmode);
General Comments 0
You need to be logged in to leave comments. Login now