diff --git a/src/language/HTMLUtils.js b/src/language/HTMLUtils.js index fd10be9b849..d8ecce3ae95 100644 --- a/src/language/HTMLUtils.js +++ b/src/language/HTMLUtils.js @@ -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; @@ -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; @@ -509,6 +510,8 @@ define(function (require, exports, module) { }; blocks.push(currentBlock); inBlock = true; + } else { + previousMode = tokenModeName; } // else, random token: ignore } diff --git a/test/spec/InlineEditorProviders-test-files/test1.php b/test/spec/InlineEditorProviders-test-files/test1.php new file mode 100644 index 00000000000..f0d07e12d2b --- /dev/null +++ b/test/spec/InlineEditorProviders-test-files/test1.php @@ -0,0 +1,14 @@ + + + + + + + + \ No newline at end of file diff --git a/test/spec/InlineEditorProviders-test.js b/test/spec/InlineEditorProviders-test.js index ecb7a2fcff9..43bb87e84d8 100644 --- a/test/spec/InlineEditorProviders-test.js +++ b/test/spec/InlineEditorProviders-test.js @@ -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);