diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2019-11-01 20:12:37 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2019-11-01 20:12:37 -0700 |
commit | dd0c17ac6c5c34b09b4e79a0fa753745bacfe122 (patch) | |
tree | 0d8bf06c82c718504b1398471d9adbbd7dd45aa1 /lib/Language/Haskell/Stylish/Step/Imports.hs | |
parent | 15eafc587c41e041194d1c4c84b2b94410a06756 (diff) | |
parent | b67a6ae12f8107b2d1714659f8a121274d5833f9 (diff) | |
download | stylish-haskell-dd0c17ac6c5c34b09b4e79a0fa753745bacfe122.tar.gz |
Merge tag 'v0.9.4.3'
v0.9.4.3
Diffstat (limited to 'lib/Language/Haskell/Stylish/Step/Imports.hs')
-rw-r--r-- | lib/Language/Haskell/Stylish/Step/Imports.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Language/Haskell/Stylish/Step/Imports.hs b/lib/Language/Haskell/Stylish/Step/Imports.hs index fc035a2..4ceb802 100644 --- a/lib/Language/Haskell/Stylish/Step/Imports.hs +++ b/lib/Language/Haskell/Stylish/Step/Imports.hs @@ -72,6 +72,7 @@ data ImportAlign data ListAlign = NewLine + | WithModuleName | WithAlias | AfterAlias deriving (Eq, Show) @@ -291,10 +292,11 @@ prettyImport columns Options{..} padQualified padName longest imp . withLast (++ (maybeSpace ++ ")")) inlineWrapper = case listAlign of - NewLine -> (paddedNoSpecBase :) . wrapRest columns listPadding' - WithAlias -> wrap columns paddedBase (inlineBaseLength + 1) + NewLine -> (paddedNoSpecBase :) . wrapRest columns listPadding' + WithModuleName -> wrap columns paddedBase (withModuleNameBaseLength + 4) + WithAlias -> wrap columns paddedBase (inlineBaseLength + 1) -- Add 1 extra space to ensure same padding as in original code. - AfterAlias -> withTail ((' ' : maybeSpace) ++) + AfterAlias -> withTail ((' ' : maybeSpace) ++) . wrap columns paddedBase (afterAliasBaseLength + 1) inlineWithBreakWrap = paddedNoSpecBase : wrapRest columns listPadding' @@ -349,6 +351,8 @@ prettyImport columns Options{..} padQualified padName longest imp inlineBaseLength = length $ base' (padImport $ compoundImportName imp) [] [] + withModuleNameBaseLength = length $ base' "" [] [] + afterAliasBaseLength = length $ base' (padImport $ compoundImportName imp) ["as " ++ as | H.ModuleName _ as <- maybeToList $ H.importAs imp] [] |