@@ -63,7 +63,7 @@ namespace ts.OutliningElementsCollector {
63
63
const currentLineStart = lineStarts [ i ] ;
64
64
const lineEnd = i + 1 === lineStarts . length ? sourceFile . getEnd ( ) : lineStarts [ i + 1 ] - 1 ;
65
65
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 ) ;
67
67
if ( ! result || isInComment ( sourceFile , currentLineStart ) ) {
68
68
continue ;
69
69
}
@@ -83,16 +83,29 @@ namespace ts.OutliningElementsCollector {
83
83
}
84
84
}
85
85
86
+ function isRegionDelimiter ( lineText : string ) {
87
+ return lineText . match ( / ^ \s * \/ \/ \s * # ( e n d ) ? r e g i o n (?: \s + ( .* ) ) ? (?: \r ) ? $ / ) ;
88
+ }
89
+
86
90
function addOutliningForLeadingCommentsForNode ( n : Node , sourceFile : SourceFile , cancellationToken : CancellationToken , out : Push < OutliningSpan > ) : void {
87
91
const comments = getLeadingCommentRangesOfNode ( n , sourceFile ) ;
88
92
if ( ! comments ) return ;
89
93
let firstSingleLineCommentStart = - 1 ;
90
94
let lastSingleLineCommentEnd = - 1 ;
91
95
let singleLineCommentCount = 0 ;
96
+ const sourceText = sourceFile . getFullText ( ) ;
92
97
for ( const { kind, pos, end } of comments ) {
93
98
cancellationToken . throwIfCancellationRequested ( ) ;
94
99
switch ( kind ) {
95
100
case SyntaxKind . SingleLineCommentTrivia :
101
+ // never fold region delimiters into single-line comment regions
102
+ const commentText = sourceText . slice ( pos , end ) ;
103
+ if ( isRegionDelimiter ( commentText ) ) {
104
+ combineAndAddMultipleSingleLineComments ( ) ;
105
+ singleLineCommentCount = 0 ;
106
+ break ;
107
+ }
108
+
96
109
// For single line comments, combine consecutive ones (2 or more) into
97
110
// a single span from the start of the first till the end of the last
98
111
if ( singleLineCommentCount === 0 ) {
0 commit comments