diff --git a/src/Options/Applicative/Help/Core.hs b/src/Options/Applicative/Help/Core.hs index 7a0bab3b..eb5bb87e 100644 --- a/src/Options/Applicative/Help/Core.hs +++ b/src/Options/Applicative/Help/Core.hs @@ -170,9 +170,12 @@ foldTree prefs s (AltNode b xs) = foldTree prefs s (BindNode x) = let rendered = wrapOver NoDefault NeverRequired (foldTree prefs s x) - withPrefix = - rendered <> stringChunk (prefMultiSuffix prefs) - in (withPrefix, NeverRequired) + + -- We always want to display the rendered option + -- if it exists, and only attach the suffix then. + withSuffix = + rendered >>= (\r -> pure r <> stringChunk (prefMultiSuffix prefs)) + in (withSuffix, NeverRequired) -- | Generate a full help text for a parser fullDesc :: ParserPrefs -> Parser a -> Chunk Doc diff --git a/tests/test.hs b/tests/test.hs index 6844a941..a66d37cc 100644 --- a/tests/test.hs +++ b/tests/test.hs @@ -855,6 +855,13 @@ prop_grouped_many_dual_flag_ellipsis = once $ r = show . extractChunk $ H.briefDesc p (x *> many x) in r === "(-a|-b) [-a|-b]..." +prop_issue_402 :: Property +prop_issue_402 = once $ + let x = some (flag' () (short 'a')) <|> some (flag' () (short 'b' <> internal)) + p = prefs (multiSuffix "...") + r = show . extractChunk $ H.briefDesc p x + in r === "(-a)..." + prop_nice_some1 :: Property prop_nice_some1 = once $ let x = Options.Applicative.NonEmpty.some1 (flag' () (short 'a'))