Skip to content

Commit d853733

Browse files
committed
fix-suggestAddTypeAnnotation regex
1 parent 50632e7 commit d853733

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ghcide/src/Development/IDE/Plugin/CodeAction.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,23 +432,25 @@ suggestAddTypeAnnotationToSatisfyContraints sourceOpt Diagnostic{_range=_range,.
432432
-- In the expression: seq "test" seq "test" (traceShow "test")
433433
-- In an equation for ‘f’:
434434
-- f = seq "test" seq "test" (traceShow "test")
435-
| Just [ty, lit] <- matchRegexUnifySpaces _message (pat False False True)
436-
<|> matchRegexUnifySpaces _message (pat False False False)
435+
| Just [ty, lit] <- matchRegexUnifySpaces _message (pat False False True False)
436+
<|> matchRegexUnifySpaces _message (pat False False False True)
437+
<|> matchRegexUnifySpaces _message (pat False False False False)
437438
= codeEdit ty lit (makeAnnotatedLit ty lit)
438439
| Just source <- sourceOpt
439-
, Just [ty, lit] <- matchRegexUnifySpaces _message (pat True True False)
440+
, Just [ty, lit] <- matchRegexUnifySpaces _message (pat True True False False)
440441
= let lit' = makeAnnotatedLit ty lit;
441442
tir = textInRange _range source
442443
in codeEdit ty lit (T.replace lit lit' tir)
443444
| otherwise = []
444445
where
445446
makeAnnotatedLit ty lit = "(" <> lit <> " :: " <> ty <> ")"
446-
pat multiple at inThe = T.concat [ ".*Defaulting the following constraint"
447+
pat multiple at inArg inExpr = T.concat [ ".*Defaulting the following constraint"
447448
, if multiple then "s" else ""
448449
, " to type ‘([^ ]+)’ "
449450
, ".*arising from the literal ‘(.+)’"
450-
, if inThe then ".+In the.+argument" else ""
451+
, if inArg then ".+In the.+argument" else ""
451452
, if at then ".+at" else ""
453+
, if inExpr then ".+In the expression" else ""
452454
, ".+In the expression"
453455
]
454456
codeEdit ty lit replacement =

0 commit comments

Comments
 (0)