Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit af230c3

Browse files
committed
Merge pull request #3073 from adobe/randy/cmv3-code-fix-2
Update inner mode detection for codemirror v3
2 parents 5c4293b + b848a57 commit af230c3

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/language/HTMLUtils.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,16 +460,18 @@ define(function (require, exports, module) {
460460
*/
461461
function findStyleBlocks(editor) {
462462
// 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;
468469

469470
while (TokenUtils.moveNextToken(ctx)) {
471+
tokenModeName = CodeMirror.innerMode(outerMode, ctx.token.state).mode.name;
470472
if (inStyleBlock) {
471473
// Check for end of this <style> block
472-
if (ctx.token.state.mode !== "css") {
474+
if (tokenModeName !== "css") {
473475
// currentStyleBlock.end is already set to pos of the last CSS token by now
474476
currentStyleBlock.text = editor.document.getRange(currentStyleBlock.start, currentStyleBlock.end);
475477
inStyleBlock = false;
@@ -478,7 +480,7 @@ define(function (require, exports, module) {
478480
}
479481
} else {
480482
// Check for start of a <style> block
481-
if (ctx.token.state.mode === "css") {
483+
if (tokenModeName === "css") {
482484
currentStyleBlock = {
483485
start: { line: ctx.pos.line, ch: ctx.pos.ch }
484486
};

0 commit comments

Comments
 (0)