Skip to content

Commit ee1ba7e

Browse files
committed
Minor update VB code folding.
1 parent 19e80a9 commit ee1ba7e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scintilla/lexers/LexVB.cxx

+7-2
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,11 @@ struct FoldLineState {
477477
}
478478
};
479479

480+
inline bool IsCodeFolding(const char *s, unsigned wordLen) noexcept {
481+
const char *p = strstr(" interface module namespace operator synclock try using ", s);
482+
return p != nullptr && p[-1] == ' ' && p[wordLen] == ' ';
483+
}
484+
480485
void FoldVBDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, LexerWordList /*keywordLists*/, Accessor &styler) {
481486
const Language language = static_cast<Language>(styler.GetPropertyInt("lexer.lang"));
482487
const Sci_PositionU endPos = startPos + lengthDoc;
@@ -511,7 +516,6 @@ void FoldVBDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, Le
511516
}
512517
if (style != initStyle) {
513518
s[wordLen] = '\0';
514-
wordLen = 0;
515519
if (style == SCE_VB_KEYWORD) {
516520
const KeywordType kwPrev = kwType;
517521
kwType = KeywordType::None;
@@ -586,7 +590,7 @@ void FoldVBDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, Le
586590
kwType = KeywordType::SkipWhile;
587591
} else if (StrEqual(s, "custom")) {
588592
kwType = KeywordType::CustomEvent;
589-
} else if (StrEqualsAny(s, "try", "using", "module", "operator", "synclock", "interface", "namespace")
593+
} else if (IsCodeFolding(s, wordLen)
590594
|| (kwPrev == KeywordType::CustomEvent && StrEqual(s, "event"))
591595
|| (chNext == '(' && StrEqualsAny(s, "addhandler", "removehandler", "raiseevent"))
592596
|| (!foldCurrent.IsInterfaceBlock() && StrEqual(s, "structure"))) {
@@ -607,6 +611,7 @@ void FoldVBDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, Le
607611
levelNext++;
608612
}
609613
}
614+
wordLen = 0;
610615
}
611616
} else if (style == SCE_VB_OPERATOR) {
612617
kwType = KeywordType::None;

0 commit comments

Comments
 (0)