Delete a 1-case alt deletes the case

This commit is contained in:
Chris Done 2017-12-07 17:00:47 +00:00
parent f7f314577e
commit 7b64bec27e

View File

@ -287,10 +287,16 @@ interpretBackspace cursor ast = do
pure w
CaseExpression l e alts
| any predicate alts -> do
case alts of
[] -> focusNode (expressionLabel e)
(CaseAlt _ _ x:_) -> focusNode (expressionLabel x)
pure (CaseExpression l e alts')
if length alts == 1
then do
w <- liftIO newExpression
focusNode (expressionLabel w)
pure w
else do
case alts of
[] -> focusNode (expressionLabel e)
(CaseAlt _ _ x:_) -> focusNode (expressionLabel x)
pure (CaseExpression l e alts')
where alts' = filter (not . predicate) alts
predicate =
((||) <$>