Move expanded binding list to standard indent level for compact layout
parent
ad34a8b9b9
commit
98c93f0d63
|
@ -676,6 +676,22 @@ import Data.List ( nub
|
||||||
, indexElem
|
, indexElem
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#test a-ridiculous-amount-of-elements
|
||||||
|
import Test ( Long
|
||||||
|
, list
|
||||||
|
, with
|
||||||
|
, items
|
||||||
|
, that
|
||||||
|
, will
|
||||||
|
, not
|
||||||
|
, quite
|
||||||
|
, fit
|
||||||
|
, onA
|
||||||
|
, single
|
||||||
|
, line
|
||||||
|
, anymore
|
||||||
|
)
|
||||||
|
|
||||||
#test with-things
|
#test with-things
|
||||||
import Test ( T
|
import Test ( T
|
||||||
, T2()
|
, T2()
|
||||||
|
|
|
@ -707,6 +707,23 @@ import Data.List (nub)
|
||||||
#test several-elements
|
#test several-elements
|
||||||
import Data.List (nub, foldl', indexElem)
|
import Data.List (nub, foldl', indexElem)
|
||||||
|
|
||||||
|
#test a-ridiculous-amount-of-elements
|
||||||
|
import Test
|
||||||
|
( Long
|
||||||
|
, list
|
||||||
|
, with
|
||||||
|
, items
|
||||||
|
, that
|
||||||
|
, will
|
||||||
|
, not
|
||||||
|
, quite
|
||||||
|
, fit
|
||||||
|
, onA
|
||||||
|
, single
|
||||||
|
, line
|
||||||
|
, anymore
|
||||||
|
)
|
||||||
|
|
||||||
#test with-things
|
#test with-things
|
||||||
import Test (T, T2(), T3(..), T4(T4), T5(T5, t5), T6((<|>)), (+))
|
import Test (T, T2(), T3(..), T4(T4), T5(T5, t5), T6((<|>)), (+))
|
||||||
|
|
||||||
|
@ -721,15 +738,8 @@ import TestJustShortEnoughModuleNameLikeThisOn as T
|
||||||
import TestJustAbitToLongModuleNameLikeThisOneI as T
|
import TestJustAbitToLongModuleNameLikeThisOneI as T
|
||||||
import TestJustShortEnoughModuleNameLike hiding ()
|
import TestJustShortEnoughModuleNameLike hiding ()
|
||||||
import TestJustAbitToLongModuleNameLikeTh hiding ()
|
import TestJustAbitToLongModuleNameLikeTh hiding ()
|
||||||
import MoreThanSufficientlyLongModuleNameWithSome ( items
|
import MoreThanSufficientlyLongModuleNameWithSome
|
||||||
, that
|
(items, that, will, not, fit, inA, compact, layout)
|
||||||
, will
|
|
||||||
, not
|
|
||||||
, fit
|
|
||||||
, inA
|
|
||||||
, compact
|
|
||||||
, layout
|
|
||||||
)
|
|
||||||
|
|
||||||
#test import-with-comments
|
#test import-with-comments
|
||||||
-- Test
|
-- Test
|
||||||
|
@ -739,62 +749,70 @@ import qualified Data.List as L (foldl') {- Test -}
|
||||||
|
|
||||||
#test import-with-comments-2
|
#test import-with-comments-2
|
||||||
|
|
||||||
import Test ( abc
|
import Test
|
||||||
, def
|
( abc
|
||||||
-- comment
|
, def
|
||||||
)
|
-- comment
|
||||||
|
)
|
||||||
|
|
||||||
#test import-with-comments-3
|
#test import-with-comments-3
|
||||||
|
|
||||||
import Test ( abc
|
import Test
|
||||||
-- comment
|
( abc
|
||||||
)
|
-- comment
|
||||||
|
)
|
||||||
|
|
||||||
#test import-with-comments-4
|
#test import-with-comments-4
|
||||||
import Test ( abc
|
import Test
|
||||||
-- comment
|
( abc
|
||||||
, def
|
-- comment
|
||||||
, ghi
|
, def
|
||||||
{- comment -}
|
, ghi
|
||||||
, jkl
|
{- comment -}
|
||||||
-- comment
|
, jkl
|
||||||
)
|
-- comment
|
||||||
|
)
|
||||||
|
|
||||||
-- Test
|
-- Test
|
||||||
import Test (test)
|
import Test (test)
|
||||||
|
|
||||||
#test import-with-comments-5
|
#test import-with-comments-5
|
||||||
import Test ( -- comment
|
import Test
|
||||||
)
|
( -- comment
|
||||||
|
)
|
||||||
|
|
||||||
#test long-bindings
|
#test long-bindings
|
||||||
import Test (longbindingNameThatoverflowsColum)
|
import Test (longbindingNameThatoverflowsColum)
|
||||||
import Test (Long(List, Of, Things))
|
import Test (Long(List, Of, Things))
|
||||||
|
|
||||||
#test things-with-with-comments
|
#test things-with-with-comments
|
||||||
import Test ( Thing( With
|
import Test
|
||||||
-- Comments
|
( Thing( With
|
||||||
, and
|
-- Comments
|
||||||
-- also
|
, and
|
||||||
, items
|
-- also
|
||||||
-- !
|
, items
|
||||||
)
|
-- !
|
||||||
)
|
)
|
||||||
import Test ( Thing( Item
|
)
|
||||||
-- and Comment
|
import Test
|
||||||
)
|
( Thing( Item
|
||||||
)
|
-- and Comment
|
||||||
import Test ( Thing( With
|
)
|
||||||
-- Comments
|
)
|
||||||
, and
|
import Test
|
||||||
-- also
|
( Thing( With
|
||||||
, items
|
-- Comments
|
||||||
-- !
|
, and
|
||||||
)
|
-- also
|
||||||
)
|
, items
|
||||||
|
-- !
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
#test prefer-dense-empty-list
|
#test prefer-dense-empty-list
|
||||||
import VeryLongModuleNameThatCouldEvenCauseAnEmptyBindingListToExpandIntoMultipleLine ()
|
import VeryLongModuleNameThatCouldEvenCauseAnEmptyBindingListToExpandIntoMultipleLine
|
||||||
|
()
|
||||||
|
|
||||||
#test preamble full-preamble
|
#test preamble full-preamble
|
||||||
{-# LANGUAGE BangPatterns #-}
|
{-# LANGUAGE BangPatterns #-}
|
||||||
|
|
|
@ -47,9 +47,6 @@ layoutImport limportD@(L _ importD) = docWrapNode limportD $ case importD of
|
||||||
ImportDecl _ (L _ modName) pkg src safe q False mas mllies -> do
|
ImportDecl _ (L _ modName) pkg src safe q False mas mllies -> do
|
||||||
importCol <- mAsk <&> _conf_layout .> _lconfig_importColumn .> confUnpack
|
importCol <- mAsk <&> _conf_layout .> _lconfig_importColumn .> confUnpack
|
||||||
indentPolicy <- mAsk <&> _conf_layout .> _lconfig_indentPolicy .> confUnpack
|
indentPolicy <- mAsk <&> _conf_layout .> _lconfig_indentPolicy .> confUnpack
|
||||||
-- NB we don't need to worry about sharing in the below code
|
|
||||||
-- (docSharedWrapper etc.) because we do not use any docAlt nodes; all
|
|
||||||
-- "decisions" are made statically.
|
|
||||||
let
|
let
|
||||||
compact = indentPolicy == IndentPolicyLeft
|
compact = indentPolicy == IndentPolicyLeft
|
||||||
modNameT = Text.pack $ moduleNameString modName
|
modNameT = Text.pack $ moduleNameString modName
|
||||||
|
@ -116,7 +113,12 @@ layoutImport limportD@(L _ importD) = docWrapNode limportD $ case importD of
|
||||||
if compact
|
if compact
|
||||||
then
|
then
|
||||||
let asDoc = maybe docEmpty makeAsDoc masT
|
let asDoc = maybe docEmpty makeAsDoc masT
|
||||||
in docSeq [importHead, asDoc, docSetBaseY $ bindingsD]
|
in docAlt
|
||||||
|
[ docForceSingleline $
|
||||||
|
docSeq [importHead, asDoc, docSetBaseY $ bindingsD]
|
||||||
|
, docAddBaseY BrIndentRegular $
|
||||||
|
docPar (docSeq [importHead, asDoc]) bindingsD
|
||||||
|
]
|
||||||
else
|
else
|
||||||
case masT of
|
case masT of
|
||||||
Just n | enoughRoom -> docLines [docSeq [importHead, asDoc], bindingLine]
|
Just n | enoughRoom -> docLines [docSeq [importHead, asDoc], bindingLine]
|
||||||
|
|
Loading…
Reference in New Issue