From aca495f73c79306c1b53c1ecd91a5d6e6e6ec861 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Mon, 11 Mar 2013 19:47:24 +1100 Subject: Bug [#1412]. Recognise a JavaScript RegExp literal in more situations. --- lexers/LexHTML.cxx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lexers/LexHTML.cxx b/lexers/LexHTML.cxx index 3793b1185..ebfd7302e 100644 --- a/lexers/LexHTML.cxx +++ b/lexers/LexHTML.cxx @@ -479,10 +479,6 @@ static bool isLineEnd(int ch) { return ch == '\r' || ch == '\n'; } -static bool isOKBeforeRE(int ch) { - return (ch == '(') || (ch == '=') || (ch == ','); -} - static bool isMakoBlockEnd(const int ch, const int chNext, const char *blockType) { if (strlen(blockType) == 0) { return ((ch == '%') && (chNext == '>')); @@ -686,6 +682,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty const CharacterSet setHTMLWord(CharacterSet::setAlphaNum, ".-_:!#", 0x80, true); const CharacterSet setTagContinue(CharacterSet::setAlphaNum, ".-_:!#[", 0x80, true); const CharacterSet setAttributeContinue(CharacterSet::setAlphaNum, ".-_:!#/", 0x80, true); + // TODO: also handle + and - (except if they're part of ++ or --) and return keywords + const CharacterSet setOKBeforeJSRE(CharacterSet::setNone, "([{=,:;!%^&*|?~"); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; @@ -1587,7 +1585,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } else if (ch == '/' && chNext == '/') { styler.ColourTo(i - 1, StateToPrint); state = SCE_HJ_COMMENTLINE; - } else if (ch == '/' && isOKBeforeRE(chPrevNonWhite)) { + } else if (ch == '/' && setOKBeforeJSRE.Contains(chPrevNonWhite)) { styler.ColourTo(i - 1, StateToPrint); state = SCE_HJ_REGEX; } else if (ch == '\"') { -- cgit v1.2.3