From 8af363b42eaa443e8d600d961aaa7011262801e1 Mon Sep 17 00:00:00 2001 From: kerams Date: Mon, 7 Nov 2022 11:52:29 +0100 Subject: [PATCH] Allow the collapsing of single line match clauses (#14248) --- src/Compiler/Service/ServiceStructure.fs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Compiler/Service/ServiceStructure.fs b/src/Compiler/Service/ServiceStructure.fs index 010f37e87d8..e9468f63357 100644 --- a/src/Compiler/Service/ServiceStructure.fs +++ b/src/Compiler/Service/ServiceStructure.fs @@ -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) =