Skip to content

Commit 8af363b

Browse files
authored
Allow the collapsing of single line match clauses (#14248)
1 parent c3a0ef2 commit 8af363b

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
@@ -493,9 +493,21 @@ module Structure =
493493
| x -> x
494494

495495
let synPat = getLastPat synPat
496-
// Collapse the scope starting with `->`
497-
let collapse = Range.endToEnd synPat.Range clause.Range
498-
rcheck Scope.MatchClause Collapse.Same e.Range collapse
496+
let synPatRange = synPat.Range
497+
let resultExprRange = e.Range
498+
499+
// Avoid rcheck because we want to be able to collapse resultExpr even if it spans a single line
500+
// but is not on the same one as the pattern
501+
if synPatRange.EndLine <> resultExprRange.EndLine then
502+
acc.Add
503+
{
504+
Scope = Scope.MatchClause
505+
Collapse = Collapse.Same
506+
Range = resultExprRange
507+
// Collapse the scope starting with `->`
508+
CollapseRange = Range.endToEnd synPatRange clause.Range
509+
}
510+
499511
parseExpr e
500512

501513
and parseAttributes (Attributes attrs) =

0 commit comments

Comments
 (0)