Skip to content

[ASP.NET, JSP] Two bugs for server side comment block #191

@zufuliu

Description

@zufuliu

Here are two bugs for server side comment <%-- ... --%> (maybe SCE_H_XCCOMMENT could be renamed? as it's not unique to XCode/JSP):
https://learn.microsoft.com/en-us/troubleshoot/developer/webapps/aspnet/development/inline-expressions#--------server-side-comments-block

lexilla/lexers/LexHTML.cxx

Lines 801 to 803 in 157f28e

19, "SCE_H_VALUE", "literal string", "Unquoted values",
20, "SCE_H_XCCOMMENT", "comment", "JSP Comment <%-- ... --%>",
21, "SCE_H_SGML_DEFAULT", "default", "SGML tags <! ... >",

# X-Code
val SCE_H_XCCOMMENT=20

First bug is code folding, I think fold whole script block should be promoted before if (chNext2 == '@') {:

lexilla/lexers/LexHTML.cxx

Lines 1516 to 1541 in 157f28e

if (chNext2 == '@') {
i += 2; // place as if it was the second next char treated
visibleChars += 2;
state = SCE_H_ASPAT;
scriptLanguage = eScriptVBS;
} else if ((chNext2 == '-') && (styler.SafeGetCharAt(i + 3) == '-')) {
styler.ColourTo(i + 3, SCE_H_ASP);
state = SCE_H_XCCOMMENT;
scriptLanguage = eScriptVBS;
continue;
} else {
if (chNext2 == '=') {
i += 2; // place as if it was the second next char treated
visibleChars += 2;
} else {
i++; // place as if it was the next char treated
visibleChars++;
}
state = StateForScript(aspScript);
scriptLanguage = aspScript;
}
styler.ColourTo(i, SCE_H_ASP);
// fold whole script
if (foldHTMLPreprocessor)
levelCurrent++;

Second bug is scriptLanguage lost on editing inside multiline comment block (e.g. press Enter before --%>), which cause comment block not terminated at handle the end of a pre-processor = Non-HTML. this is same for multiline SCE_H_ASPAT. Change ScriptOfState() to return eScriptVBS for SCE_H_XCCOMMENT and SCE_H_ASPAT fixed the problem. also ScriptOfState() likely has bug for SCE_HPHP_COMPLEX_VARIABLE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    aspCaused by ASP or ASP.NET for the html lexerhtmlCaused by the hypertext lexer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions