From d5c826aaa25de961b84a5c8a288f81d51a380e2d Mon Sep 17 00:00:00 2001 From: Piotr Tomiak Date: Thu, 28 May 2020 13:45:05 +0200 Subject: [PATCH] Html: fix incorrect HTML lexer behaviour. GitOrigin-RevId: 3eb230e2be097b4db8c341902434ad4376eacebc --- .../src/com/intellij/lexer/BaseHtmlLexer.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xml/xml-psi-impl/src/com/intellij/lexer/BaseHtmlLexer.java b/xml/xml-psi-impl/src/com/intellij/lexer/BaseHtmlLexer.java index 91773d0a7930..2da189bd6253 100644 --- a/xml/xml-psi-impl/src/com/intellij/lexer/BaseHtmlLexer.java +++ b/xml/xml-psi-impl/src/com/intellij/lexer/BaseHtmlLexer.java @@ -318,6 +318,7 @@ public abstract class BaseHtmlLexer extends DelegateLexer { protected int skipToTheEndOfTheEmbeddment() { Lexer base = getDelegate(); + int initialStart = base.getTokenStart(); int tokenEnd = base.getTokenEnd(); int lastState = 0; int lastStart = 0; @@ -375,8 +376,15 @@ public abstract class BaseHtmlLexer extends DelegateLexer { } } - base.start(buf,lastStart,getBufferEnd(),lastState); - base.getTokenType(); + if (lastStart < initialStart) { + // empty embeddment + base.start(buf, initialStart, getBufferEnd(), lastState); + TokenHandler tokenHandler = tokenHandlers.get(base.getTokenType()); + if (tokenHandler != null) tokenHandler.handleElement(this); + } else { + base.start(buf, lastStart, getBufferEnd(), lastState); + base.getTokenType(); + } } else if (seenAttribute) { while(true) { if (!isValidAttributeValueTokenType(base.getTokenType())) break;