more fidgeting before starting over

This commit is contained in:
Nicholas Bollweg (Nick) 2014-12-01 19:27:43 -05:00
parent 5858350cc3
commit c72ad2754c
3 changed files with 9 additions and 10 deletions

View File

@ -624,7 +624,8 @@ define([
var info = (mode && mode.mode && mode.mime && mode) || var info = (mode && mode.mode && mode.mime && mode) ||
CodeMirror.findModeByName(modename) || CodeMirror.findModeByName(modename) ||
CodeMirror.findModeByExtension(modename.split(".").slice(-1)) || CodeMirror.findModeByExtension(modename.split(".").slice(-1)) ||
CodeMirror.findModeByMIME(modename); CodeMirror.findModeByMIME(modename) ||
{mode: modename, mime: modename};
require([ require([
// might want to use CodeMirror.modeURL here // might want to use CodeMirror.modeURL here

View File

@ -41,12 +41,10 @@ function($,
cm.clearHistory(); cm.clearHistory();
// Find and load the highlighting mode // Find and load the highlighting mode
var modeinfo = CodeMirror.findModeByMIME(model.mimetype); utils.requireCodeMirrorMode(model.mimetype, function(spec) {
if (modeinfo) { var mode = CodeMirror.getMode({}, spec);
utils.requireCodeMirrorMode(modeinfo.mode, function() { cm.setOption('mode', mode);
cm.setOption('mode', modeinfo.mode); });
});
}
that.save_enabled = true; that.save_enabled = true;
}, },
function(error) { function(error) {

View File

@ -1587,14 +1587,14 @@ define([
codecell.CodeCell.options_default.cm_config.mode = newmode; codecell.CodeCell.options_default.cm_config.mode = newmode;
var that = this; var that = this;
utils.requireCodeMirrorMode(newmode, function () { utils.requireCodeMirrorMode(newmode, function (spec) {
that.get_cells().map(function(cell, i) { that.get_cells().map(function(cell, i) {
if (cell.cell_type === 'code'){ if (cell.cell_type === 'code'){
cell.code_mirror.setOption('mode', newmode); cell.code_mirror.setOption('mode', spec);
// This is currently redundant, because cm_config ends up as // This is currently redundant, because cm_config ends up as
// codemirror's own .options object, but I don't want to // codemirror's own .options object, but I don't want to
// rely on that. // rely on that.
cell.cm_config.mode = newmode; cell.cm_config.mode = spec;
} }
}); });
}); });