@@ -477,6 +477,11 @@ struct FoldLineState {
477
477
}
478
478
};
479
479
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
+
480
485
void FoldVBDoc (Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, LexerWordList /* keywordLists*/ , Accessor &styler) {
481
486
const Language language = static_cast <Language>(styler.GetPropertyInt (" lexer.lang" ));
482
487
const Sci_PositionU endPos = startPos + lengthDoc;
@@ -511,7 +516,6 @@ void FoldVBDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, Le
511
516
}
512
517
if (style != initStyle) {
513
518
s[wordLen] = ' \0 ' ;
514
- wordLen = 0 ;
515
519
if (style == SCE_VB_KEYWORD) {
516
520
const KeywordType kwPrev = kwType;
517
521
kwType = KeywordType::None;
@@ -586,7 +590,7 @@ void FoldVBDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, Le
586
590
kwType = KeywordType::SkipWhile;
587
591
} else if (StrEqual (s, " custom" )) {
588
592
kwType = KeywordType::CustomEvent;
589
- } else if (StrEqualsAny (s, " try " , " using " , " module " , " operator " , " synclock " , " interface " , " namespace " )
593
+ } else if (IsCodeFolding (s, wordLen )
590
594
|| (kwPrev == KeywordType::CustomEvent && StrEqual (s, " event" ))
591
595
|| (chNext == ' (' && StrEqualsAny (s, " addhandler" , " removehandler" , " raiseevent" ))
592
596
|| (!foldCurrent.IsInterfaceBlock () && StrEqual (s, " structure" ))) {
@@ -607,6 +611,7 @@ void FoldVBDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, Le
607
611
levelNext++;
608
612
}
609
613
}
614
+ wordLen = 0 ;
610
615
}
611
616
} else if (style == SCE_VB_OPERATOR) {
612
617
kwType = KeywordType::None;
0 commit comments