@@ -142,14 +142,13 @@ p_match' placer pretty style isInfix m_pats m_grhss = do
142 return inci'
142 return inci'
145− -- Calculate a 'SrcSpan' that captures the end of the name\/pattern part
145+ -- Calculate position of end of patterns. This is useful when we decide
146− -- of the match. This is used to tell if we need to have the body on a
146+ -- about putting certain constructions in hanging positions.
148− endOfPatsSpan = srcLocSpan . srcSpanEnd <$> case NE.nonEmpty m_pats of
147+ endOfPats = case NE.nonEmpty m_pats of
149 Nothing -> case style of
148 Nothing -> case style of
150− Function name -> Just $ getLoc name
149+ Function name -> (Just . srcSpanEnd . getLoc) name
151 _ -> Nothing
150 _ -> Nothing
152− Just pats -> Just . getLoc $ NE.last pats
151+ Just pats -> (Just . srcSpanEnd . getLoc . NE.last) pats
153 isCase = \case
152 isCase = \case
154 Case -> True
153 Case -> True
155 LambdaCase -> True
154 LambdaCase -> True
@@ -166,8 +165,16 @@ p_match' placer pretty style isInfix m_pats m_grhss = do
166 _ -> txt " ->"
165 _ -> txt " ->"
167 let grhssSpan = combineSrcSpans' $
166 let grhssSpan = combineSrcSpans' $
168 getGRHSSpan . unLoc <$> NE.fromList grhssGRHSs
167 getGRHSSpan . unLoc <$> NE.fromList grhssGRHSs
169− patGrhssSpan = maybe grhssSpan (combineSrcSpans grhssSpan) endOfPatsSpan
168+ patGrhssSpan = maybe grhssSpan
169+ (combineSrcSpans grhssSpan . srcLocSpan) endOfPats
170− placement = blockPlacement placer grhssGRHSs
172+ Nothing -> blockPlacement placer grhssGRHSs
175+ (mkSrcSpan spn (srcSpanStart grhssSpan))
176+ then blockPlacement placer grhssGRHSs
171 inciLocalBinds = case placement of
178 inciLocalBinds = case placement of
172 Normal -> id
179 Normal -> id
173 Hanging -> inci
180 Hanging -> inci