Skip to content

Commit 546c046

Browse files
authored
Make block comments collapsible (#14808)
Thank you for this contribution Kevin
1 parent 4091685 commit 546c046

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/Compiler/Service/ServiceStructure.fs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ module Structure =
850850
elif line.StartsWithOrdinal("//") then Some SingleLine
851851
else None
852852

853-
let getCommentRanges (lines: string[]) =
853+
let getCommentRanges trivia (lines: string[]) =
854854
let rec loop (lastLineNum, currentComment, result as state) (lines: string list) lineNum =
855855
match lines with
856856
| [] -> state
@@ -904,6 +904,18 @@ module Structure =
904904
})
905905
|> acc.AddRange
906906

907+
for trivia in trivia do
908+
match trivia with
909+
| CommentTrivia.BlockComment m when m.StartLine <> m.EndLine ->
910+
{
911+
Scope = Scope.Comment
912+
Collapse = Collapse.Same
913+
Range = m
914+
CollapseRange = m
915+
}
916+
|> acc.Add
917+
| _ -> ()
918+
907919
//=======================================//
908920
// Signature File AST Traversal //
909921
//=======================================//
@@ -1107,10 +1119,10 @@ module Structure =
11071119
| ParsedInput.ImplFile file ->
11081120
file.Contents |> List.iter parseModuleOrNamespace
11091121
collectConditionalDirectives file.Trivia.ConditionalDirectives sourceLines
1110-
getCommentRanges sourceLines
1122+
getCommentRanges file.Trivia.CodeComments sourceLines
11111123
| ParsedInput.SigFile file ->
11121124
file.Contents |> List.iter parseModuleOrNamespaceSigs
11131125
collectConditionalDirectives file.Trivia.ConditionalDirectives sourceLines
1114-
getCommentRanges sourceLines
1126+
getCommentRanges file.Trivia.CodeComments sourceLines
11151127

11161128
acc :> seq<_>

0 commit comments

Comments
 (0)