Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/language/HTMLUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ define(function (require, exports, module) {
currentBlock = null,
inBlock = false,
outerMode = editor._codeMirror.getMode(),
tokenModeName;
tokenModeName,
previousMode;

while (TokenUtils.moveNextToken(ctx, false)) {
tokenModeName = CodeMirror.innerMode(outerMode, ctx.token.state).mode.name;
Expand All @@ -494,7 +495,7 @@ define(function (require, exports, module) {
currentBlock.end = currentBlock.start;
}
// Check for end of this block
if (tokenModeName !== modeName) {
if (tokenModeName === previousMode) {
// currentBlock.end is already set to pos of the last token by now
currentBlock.text = editor.document.getRange(currentBlock.start, currentBlock.end);
inBlock = false;
Expand All @@ -509,6 +510,8 @@ define(function (require, exports, module) {
};
blocks.push(currentBlock);
inBlock = true;
} else {
previousMode = tokenModeName;
}
// else, random token: ignore
}
Expand Down
14 changes: 14 additions & 0 deletions test/spec/InlineEditorProviders-test-files/test1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<style type="text/css">
{{0}} body {
background: url("<?php echo $img; ?>") no-repeat;
background-size: 100% 100%;
color: white;
}
</style>
</head>

<bo{{1}}dy onclick="goHome()"></body>
</html>
15 changes: 15 additions & 0 deletions test/spec/InlineEditorProviders-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,21 @@ define(function (require, exports, module) {
});


it("should open a type selector and show correct range including the embedded php", function () {
initInlineTest("test1.php", 1);

runs(function () {
var inlineWidget = EditorManager.getCurrentFullEditor().getInlineWidgets()[0];
var inlinePos = inlineWidget.editor.getCursorPos();

// verify cursor position and displayed range in inline editor
expect(inlinePos).toEqual(infos["test1.php"].offsets[0]);
expect(inlineWidget.editor).toHaveInlineEditorRange(toRange(4, 8));

inlineWidget = null;
});
});

it("should open a type selector on opening tag", function () {
initInlineTest("test1.html", 0);

Expand Down