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

Commit fbccf88

Browse files
committed
Use a more generic solution by tracking previous mode and exit only if we're back to previous mode.
1 parent ceec915 commit fbccf88

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/language/HTMLUtils.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,8 @@ define(function (require, exports, module) {
484484
currentBlock = null,
485485
inBlock = false,
486486
outerMode = editor._codeMirror.getMode(),
487-
tokenModeName;
487+
tokenModeName,
488+
previousMode;
488489

489490
while (TokenUtils.moveNextToken(ctx, false)) {
490491
tokenModeName = CodeMirror.innerMode(outerMode, ctx.token.state).mode.name;
@@ -493,10 +494,8 @@ define(function (require, exports, module) {
493494
// Handle empty blocks
494495
currentBlock.end = currentBlock.start;
495496
}
496-
// Check for end of this block which normally is the </style> tag
497-
// with tokenModeName in "xml". If we encounter embedded php code, we
498-
// will get "clike" tokenModeName and we need to skip all of them.
499-
if (tokenModeName !== "clike" && tokenModeName !== modeName) {
497+
// Check for end of this block
498+
if (tokenModeName === previousMode) {
500499
// currentBlock.end is already set to pos of the last token by now
501500
currentBlock.text = editor.document.getRange(currentBlock.start, currentBlock.end);
502501
inBlock = false;
@@ -511,6 +510,8 @@ define(function (require, exports, module) {
511510
};
512511
blocks.push(currentBlock);
513512
inBlock = true;
513+
} else {
514+
previousMode = tokenModeName;
514515
}
515516
// else, random token: ignore
516517
}

0 commit comments

Comments
 (0)