@@ -460,16 +460,18 @@ define(function (require, exports, module) {
460
460
*/
461
461
function findStyleBlocks ( editor ) {
462
462
// Start scanning from beginning of file
463
- var ctx = TokenUtils . getInitialContext ( editor . _codeMirror , { line : 0 , ch : 0 } ) ;
464
-
465
- var styleBlocks = [ ] ;
466
- var currentStyleBlock = null ;
467
- var inStyleBlock = false ;
463
+ var ctx = TokenUtils . getInitialContext ( editor . _codeMirror , { line : 0 , ch : 0 } ) ,
464
+ styleBlocks = [ ] ,
465
+ currentStyleBlock = null ,
466
+ inStyleBlock = false ,
467
+ outerMode = editor . _codeMirror . getMode ( ) ,
468
+ tokenModeName ;
468
469
469
470
while ( TokenUtils . moveNextToken ( ctx ) ) {
471
+ tokenModeName = CodeMirror . innerMode ( outerMode , ctx . token . state ) . mode . name ;
470
472
if ( inStyleBlock ) {
471
473
// Check for end of this <style> block
472
- if ( ctx . token . state . mode !== "css" ) {
474
+ if ( tokenModeName !== "css" ) {
473
475
// currentStyleBlock.end is already set to pos of the last CSS token by now
474
476
currentStyleBlock . text = editor . document . getRange ( currentStyleBlock . start , currentStyleBlock . end ) ;
475
477
inStyleBlock = false ;
@@ -478,7 +480,7 @@ define(function (require, exports, module) {
478
480
}
479
481
} else {
480
482
// Check for start of a <style> block
481
- if ( ctx . token . state . mode === "css" ) {
483
+ if ( tokenModeName === "css" ) {
482
484
currentStyleBlock = {
483
485
start : { line : ctx . pos . line , ch : ctx . pos . ch }
484
486
} ;
0 commit comments