Skip to content

Commit

Permalink
Minor update VB code folding.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Jan 19, 2025
1 parent 19e80a9 commit ee1ba7e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scintilla/lexers/LexVB.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,11 @@ struct FoldLineState {
}
};

inline bool IsCodeFolding(const char *s, unsigned wordLen) noexcept {
const char *p = strstr(" interface module namespace operator synclock try using ", s);
return p != nullptr && p[-1] == ' ' && p[wordLen] == ' ';
}

void FoldVBDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, LexerWordList /*keywordLists*/, Accessor &styler) {
const Language language = static_cast<Language>(styler.GetPropertyInt("lexer.lang"));
const Sci_PositionU endPos = startPos + lengthDoc;
Expand Down Expand Up @@ -511,7 +516,6 @@ void FoldVBDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, Le
}
if (style != initStyle) {
s[wordLen] = '\0';
wordLen = 0;
if (style == SCE_VB_KEYWORD) {
const KeywordType kwPrev = kwType;
kwType = KeywordType::None;
Expand Down Expand Up @@ -586,7 +590,7 @@ void FoldVBDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, Le
kwType = KeywordType::SkipWhile;
} else if (StrEqual(s, "custom")) {
kwType = KeywordType::CustomEvent;
} else if (StrEqualsAny(s, "try", "using", "module", "operator", "synclock", "interface", "namespace")
} else if (IsCodeFolding(s, wordLen)
|| (kwPrev == KeywordType::CustomEvent && StrEqual(s, "event"))
|| (chNext == '(' && StrEqualsAny(s, "addhandler", "removehandler", "raiseevent"))
|| (!foldCurrent.IsInterfaceBlock() && StrEqual(s, "structure"))) {
Expand All @@ -607,6 +611,7 @@ void FoldVBDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, Le
levelNext++;
}
}
wordLen = 0;
}
} else if (style == SCE_VB_OPERATOR) {
kwType = KeywordType::None;
Expand Down

0 comments on commit ee1ba7e

Please sign in to comment.