@@ -63,7 +63,7 @@ namespace ts.OutliningElementsCollector {
6363 const currentLineStart = lineStarts [ i ] ;
6464 const lineEnd = i + 1 === lineStarts . length ? sourceFile . getEnd ( ) : lineStarts [ i + 1 ] - 1 ;
6565 const lineText = sourceFile . text . substring ( currentLineStart , lineEnd ) ;
66- const result = lineText . match ( / ^ \s * \/ \/ \s * # ( e n d ) ? r e g i o n (?: \s + ( . * ) ) ? (?: \r ) ? $ / ) ;
66+ const result = isRegionDelimiter ( lineText ) ;
6767 if ( ! result || isInComment ( sourceFile , currentLineStart ) ) {
6868 continue ;
6969 }
@@ -83,16 +83,30 @@ namespace ts.OutliningElementsCollector {
8383 }
8484 }
8585
86+ const regionDelimiterRegExp = / ^ \s * \/ \/ \s * # ( e n d ) ? r e g i o n (?: \s + ( .* ) ) ? (?: \r ) ? $ / ;
87+ function isRegionDelimiter ( lineText : string ) {
88+ return regionDelimiterRegExp . exec ( lineText ) ;
89+ }
90+
8691 function addOutliningForLeadingCommentsForNode ( n : Node , sourceFile : SourceFile , cancellationToken : CancellationToken , out : Push < OutliningSpan > ) : void {
8792 const comments = getLeadingCommentRangesOfNode ( n , sourceFile ) ;
8893 if ( ! comments ) return ;
8994 let firstSingleLineCommentStart = - 1 ;
9095 let lastSingleLineCommentEnd = - 1 ;
9196 let singleLineCommentCount = 0 ;
97+ const sourceText = sourceFile . getFullText ( ) ;
9298 for ( const { kind, pos, end } of comments ) {
9399 cancellationToken . throwIfCancellationRequested ( ) ;
94100 switch ( kind ) {
95101 case SyntaxKind . SingleLineCommentTrivia :
102+ // never fold region delimiters into single-line comment regions
103+ const commentText = sourceText . slice ( pos , end ) ;
104+ if ( isRegionDelimiter ( commentText ) ) {
105+ combineAndAddMultipleSingleLineComments ( ) ;
106+ singleLineCommentCount = 0 ;
107+ break ;
108+ }
109+
96110 // For single line comments, combine consecutive ones (2 or more) into
97111 // a single span from the start of the first till the end of the last
98112 if ( singleLineCommentCount === 0 ) {
0 commit comments