Skip to content

imports long list align + list align behaviour regression when set to newline #462

@paolino

Description

@paolino

In version 0.11.0.3, a configuration containing

     list_align: new_line
     long_list_align: new_line_multiline

was producing a nice consistent layout with all imported stuff in a new line and longer than 80 import lines broken in multiple lines

i.e. this test would have passed

case26b :: Assertion
case26b =
    assertSnippet (step (Just 80) options)
    [ "import Data.Map (Map)"
    , "import Data.List (concat, foldl, foldr, head, init, last, length, map, null, reverse, tail, (++))"
    ]
    [ "import Data.List"
    , "    ( concat"
    , "    , foldl"
    , "    , foldr"
    , "    , head"
    , "    , init"
    , "    , last"
    , "    , length"
    , "    , map"
    , "    , null"
    , "    , reverse"
    , "    , tail"
    , "    , (++)"
    , "    )"
    , "import Data.Map"
    , "    (Map)"
    ]
  where
    options = defaultOptions { listAlign = NewLine, importAlign = None, longListAlign = Multiline}

But now, on 0.14.5.0, I cannot reproduce it. In fact, I get

expected: 
import Data.List
    ( concat
    , foldl
    , foldr
    , head
    , init
    , last
    , length
    , map
    , null
    , reverse
    , tail
    , (++)
    )
import Data.Map
    (Map)

 but got: 
import Data.List
    ( concat
    , foldl
    , foldr
    , head
    , init
    , last
    , length
    , map
    , null
    , reverse
    , tail
    , (++)
    )
import Data.Map (Map)

where the (Map) is not on a new line.

also, without the longListAlign , the listAlign option is respected

i.e. this test passes

case26a :: Assertion
case26a =
    assertSnippet (step (Just 80) options)
    [ "import Data.Map (Map)"
    , "import Data.List (concat, foldl, foldr, head, init, last, length, map, null, reverse, tail, (++))"
    ]
    [ "import Data.List"
    , "    (concat, foldl, foldr, head, init, last, length, map, null, reverse, tail,"
    , "    (++))"
    , "import Data.Map"
    , "    (Map)"
    ]
  where
    options = defaultOptions { listAlign = NewLine, importAlign = None}

Maybe I need a different combination of the options? Any help appreciated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions