Skip to content

Commit

Permalink
Allow the collapsing of single line match clauses (#14248)
Browse files Browse the repository at this point in the history
  • Loading branch information
kerams authored Nov 7, 2022
1 parent c3a0ef2 commit 8af363b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Compiler/Service/ServiceStructure.fs
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,21 @@ module Structure =
| x -> x

let synPat = getLastPat synPat
// Collapse the scope starting with `->`
let collapse = Range.endToEnd synPat.Range clause.Range
rcheck Scope.MatchClause Collapse.Same e.Range collapse
let synPatRange = synPat.Range
let resultExprRange = e.Range

// Avoid rcheck because we want to be able to collapse resultExpr even if it spans a single line
// but is not on the same one as the pattern
if synPatRange.EndLine <> resultExprRange.EndLine then
acc.Add
{
Scope = Scope.MatchClause
Collapse = Collapse.Same
Range = resultExprRange
// Collapse the scope starting with `->`
CollapseRange = Range.endToEnd synPatRange clause.Range
}

parseExpr e

and parseAttributes (Attributes attrs) =
Expand Down

0 comments on commit 8af363b

Please sign in to comment.