@@ -1869,14 +1869,20 @@ define(function (require, exports, module) {
18691869 *
18701870 * @param {!{line: number, ch: number} } start The start of the range to check.
18711871 * @param {!{line: number, ch: number} } end The end of the range to check.
1872+ * @param {boolean= } knownMixed Whether we already know we're in a mixed mode and need to check both
1873+ * the start and end.
18721874 * @return {?(Object|string) } Name of syntax-highlighting mode, or object containing a "name" property
18731875 * naming the mode along with configuration options required by the mode.
18741876 * See {@link LanguageManager#getLanguageForPath()} and {@link Language#getMode()}.
18751877 */
1876- Editor . prototype . getModeForRange = function ( start , end ) {
1877- var startMode = TokenUtils . getModeAt ( this . _codeMirror , start ) ,
1878+ Editor . prototype . getModeForRange = function ( start , end , knownMixed ) {
1879+ var outerMode = this . _codeMirror . getMode ( ) ,
1880+ startMode = TokenUtils . getModeAt ( this . _codeMirror , start ) ,
18781881 endMode = TokenUtils . getModeAt ( this . _codeMirror , end ) ;
1879- if ( ! startMode || ! endMode || startMode . name !== endMode . name ) {
1882+ if ( ! knownMixed && outerMode . name === startMode . name ) {
1883+ // Mode does not vary: just use the editor-wide mode name
1884+ return this . _codeMirror . getOption ( "mode" ) ;
1885+ } else if ( ! startMode || ! endMode || startMode . name !== endMode . name ) {
18801886 return null ;
18811887 } else {
18821888 return startMode ;
@@ -1921,7 +1927,7 @@ define(function (require, exports, module) {
19211927 return false ;
19221928 }
19231929
1924- var rangeMode = self . getModeForRange ( sel . start , sel . end ) ;
1930+ var rangeMode = self . getModeForRange ( sel . start , sel . end , true ) ;
19251931 return ( ! rangeMode || rangeMode . name !== startMode . name ) ;
19261932 } ) ;
19271933 if ( hasMixedSel ) {
0 commit comments