-
Notifications
You must be signed in to change notification settings - Fork 78
Open
Labels
committedIssue fixed in repository but not in releaseIssue fixed in repository but not in releasehtmlCaused by the hypertext lexerCaused by the hypertext lexer
Description
Opened to discuss and backport zufuliu/notepad4@1c2360f
else if (state == SCE_HBA_DEFAULT)block is not reachable afterint state = stateForPrintState(StateToPrint);, and can be merged with precedingif (state == SCE_HB_DEFAULT)block.
Lines 2706 to 2716 in c14de3d
} else if (state == SCE_HBA_DEFAULT) { // One of the above succeeded if ((ch == '\"') && (nonEmptySegment)) { state = SCE_HBA_STRING; } else if (ch == '\'') { state = SCE_HBA_COMMENTLINE; } else if (IsAWordStart(ch)) { state = SCE_HBA_WORD; } else if (IsOperator(ch)) { styler.ColourTo(i, SCE_HBA_DEFAULT); } } else if (state == SCE_HJ_DEFAULT) { // One of the above succeeded if (state == SCE_HB_DEFAULT)block insidecase SCE_HB_WORD:can be merged withif (state == SCE_HB_DEFAULT)block after the big switch.
Lines 2379 to 2390 in c14de3d
if (state == SCE_HB_DEFAULT) { if (ch == '\"') { state = SCE_HB_STRING; } else if (ch == '\'') { state = SCE_HB_COMMENTLINE; } else if (IsOperator(ch)) { styler.ColourTo(i, statePrintForState(SCE_HB_DEFAULT, inScriptType)); state = SCE_HB_DEFAULT; } } } break;
Lines 2696 to 2706 in c14de3d
if (state == SCE_HB_DEFAULT) { // One of the above succeeded if ((ch == '\"') && (nonEmptySegment)) { state = SCE_HB_STRING; } else if (ch == '\'') { state = SCE_HB_COMMENTLINE; } else if (IsAWordStart(ch)) { state = SCE_HB_WORD; } else if (IsOperator(ch)) { styler.ColourTo(i, SCE_HB_DEFAULT); } } else if (state == SCE_HBA_DEFAULT) { // One of the above succeeded - state change block inside
case SCE_HJ_WORD:can be merged withelse if (state == SCE_HJ_DEFAULT)block after the big switch.
Lines 2240 to 2264 in c14de3d
state = SCE_HJ_DEFAULT; if (ch == '/' && chNext == '*') { i++; if (chNext2 == '*') state = SCE_HJ_COMMENTDOC; else state = SCE_HJ_COMMENT; } else if (ch == '/' && chNext == '/') { state = SCE_HJ_COMMENTLINE; } else if (ch == '\"') { state = SCE_HJ_DOUBLESTRING; } else if (ch == '\'') { state = SCE_HJ_SINGLESTRING; } else if (ch == '`') { state = SCE_HJ_TEMPLATELITERAL; } else if ((ch == '-') && (chNext == '-') && (chNext2 == '>')) { styler.ColourTo(i - 1, StateToPrint); state = SCE_HJ_COMMENTLINE; i += 2; } else if (IsOperator(ch)) { styler.ColourTo(i, statePrintForState(SCE_HJ_SYMBOLS, inScriptType)); state = SCE_HJ_DEFAULT; } } break;
Lines 2716 to 2736 in c14de3d
} else if (state == SCE_HJ_DEFAULT) { // One of the above succeeded if (ch == '/' && chNext == '*') { i++; if (styler.SafeGetCharAt(i + 1) == '*') state = SCE_HJ_COMMENTDOC; else state = SCE_HJ_COMMENT; } else if (ch == '/' && chNext == '/') { state = SCE_HJ_COMMENTLINE; } else if ((ch == '\"') && (nonEmptySegment)) { state = SCE_HJ_DOUBLESTRING; } else if ((ch == '\'') && (nonEmptySegment)) { state = SCE_HJ_SINGLESTRING; } else if ((ch == '`') && (nonEmptySegment)) { state = SCE_HJ_TEMPLATELITERAL; } else if (IsAWordStart(ch)) { state = SCE_HJ_WORD; } else if (IsOperator(ch)) { styler.ColourTo(i, statePrintForState(SCE_HJ_SYMBOLS, inScriptType)); } } nonEmptySegmentcheck could be eliminated by usingcontinue.
Line 2695 in c14de3d
const bool nonEmptySegment = i >= static_cast<Sci_Position>(styler.GetStartSegment());
Other changes not yet made:
bool tagOpenedis never used / tested, so can be removed.
Line 1246 in c14de3d
bool tagOpened = (lineState >> 2) & 0x01; // 1 bit to know if we are in an opened tag - Due to backtracking to start of line not inside tag states,
bool tagClosingandbool isLanguageTypecan be omitted fromlineState.
Lines 1206 to 1209 in c14de3d
// If inside a tag, it may be a script tag, so reread from the start of line starting tag to ensure any language tags are seen // PHP string can be heredoc, must find a delimiter first. Reread from beginning of line containing the string, to get the correct lineState if (StyleNeedsBacktrack(state)) { while ((startPos > 0) && (StyleNeedsBacktrack(styler.StyleIndexAt(startPos - 1)))) {
Lines 671 to 673 in c14de3d
constexpr bool StyleNeedsBacktrack(int state) noexcept { return InTagState(state) || isPHPStringState(state); } - (Maybe complex changes) defer and merge state change for JavaScript and VBScript to blocks after the big switch.
Lines 2188 to 2191 in c14de3d
case SCE_HJ_DEFAULT: case SCE_HJ_START: case SCE_HJ_SYMBOLS: if (IsAWordStart(ch)) {
Lines 2350 to 2352 in c14de3d
case SCE_HB_DEFAULT: case SCE_HB_START: if (IsAWordStart(ch)) {
Metadata
Metadata
Assignees
Labels
committedIssue fixed in repository but not in releaseIssue fixed in repository but not in releasehtmlCaused by the hypertext lexerCaused by the hypertext lexer