Show More
@@ -97,14 +97,17 b' function($,' | |||||
97 |
|
97 | |||
98 | Editor.prototype._set_mode_for_model = function (model) { |
|
98 | Editor.prototype._set_mode_for_model = function (model) { | |
99 | /** Set the CodeMirror mode based on the file model */ |
|
99 | /** Set the CodeMirror mode based on the file model */ | |
100 |
|
100 | |||
101 | // Find and load the highlighting mode, |
|
101 | // Find and load the highlighting mode, | |
102 | // first by mime-type, then by file extension |
|
102 | // first by mime-type, then by file extension | |
103 | var modeinfo = CodeMirror.findModeByMIME(model.mimetype); |
|
103 | var modeinfo; | |
104 |
if (mode |
|
104 | if (model.mimetype) { | |
|
105 | modeinfo = CodeMirror.findModeByMIME(model.mimetype); | |||
|
106 | } | |||
|
107 | if (!modeinfo || modeinfo.mode === "null") { | |||
105 | // find by mime failed, use find by ext |
|
108 | // find by mime failed, use find by ext | |
106 | var ext_idx = model.name.lastIndexOf('.'); |
|
109 | var ext_idx = model.name.lastIndexOf('.'); | |
107 |
|
110 | |||
108 | if (ext_idx > 0) { |
|
111 | if (ext_idx > 0) { | |
109 | // CodeMirror.findModeByExtension wants extension without '.' |
|
112 | // CodeMirror.findModeByExtension wants extension without '.' | |
110 | modeinfo = CodeMirror.findModeByExtension(model.name.slice(ext_idx + 1)); |
|
113 | modeinfo = CodeMirror.findModeByExtension(model.name.slice(ext_idx + 1)); | |
@@ -114,7 +117,7 b' function($,' | |||||
114 | this.set_codemirror_mode(modeinfo); |
|
117 | this.set_codemirror_mode(modeinfo); | |
115 | } |
|
118 | } | |
116 | }; |
|
119 | }; | |
117 |
|
120 | |||
118 | Editor.prototype.set_codemirror_mode = function (modeinfo) { |
|
121 | Editor.prototype.set_codemirror_mode = function (modeinfo) { | |
119 | /** set the codemirror mode from a modeinfo struct */ |
|
122 | /** set the codemirror mode from a modeinfo struct */ | |
120 | var that = this; |
|
123 | var that = this; |
General Comments 0
You need to be logged in to leave comments.
Login now