Fix IndentPolicyMultiple for indentAmount>4
parent
e91bb6aec9
commit
dd53948a23
|
@ -12,14 +12,26 @@ func =
|
||||||
mweroiuxlskdfjlksjdflkjsdfljksldkjflkjsdflkj
|
mweroiuxlskdfjlksjdflkjsdfljksldkjflkjsdflkj
|
||||||
+ mweroiuxlskdfjlksjdflkjsdfljksldkjflkjsdflkj
|
+ mweroiuxlskdfjlksjdflkjsdfljksldkjflkjsdflkj
|
||||||
|
|
||||||
#test let
|
#test let indAmount=4
|
||||||
-- brittany { lconfig_indentAmount: 4, lconfig_indentPolicy: IndentPolicyMultiple }
|
-- brittany { lconfig_indentAmount: 4, lconfig_indentPolicy: IndentPolicyMultiple }
|
||||||
foo = do
|
foo = do
|
||||||
let
|
let aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
|
||||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
|
|
||||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
foo
|
foo
|
||||||
|
|
||||||
|
#test let indAmount=8
|
||||||
|
-- brittany { lconfig_indentAmount: 8, lconfig_indentPolicy: IndentPolicyMultiple }
|
||||||
|
foo = do
|
||||||
|
let aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
|
||||||
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
|
foo
|
||||||
|
foo = do
|
||||||
|
let aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
|
||||||
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
|
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
|
foo
|
||||||
|
|
||||||
#test nested do-block
|
#test nested do-block
|
||||||
-- brittany { lconfig_indentAmount: 4, lconfig_indentPolicy: IndentPolicyMultiple }
|
-- brittany { lconfig_indentAmount: 4, lconfig_indentPolicy: IndentPolicyMultiple }
|
||||||
foo = asdyf8asdf
|
foo = asdyf8asdf
|
||||||
|
|
|
@ -141,24 +141,14 @@ transformAlts =
|
||||||
BDFSeparator -> processSpacingSimple bdX $> bdX
|
BDFSeparator -> processSpacingSimple bdX $> bdX
|
||||||
BDFAddBaseY indent bd -> do
|
BDFAddBaseY indent bd -> do
|
||||||
acp <- mGet
|
acp <- mGet
|
||||||
indAmount <- mAsk <&> _conf_layout .> _lconfig_indentAmount .> confUnpack
|
indAdd <- fixIndentationForMultiple acp indent
|
||||||
indPolicy <- mAsk <&> _conf_layout .> _lconfig_indentPolicy .> confUnpack
|
mSet $ acp { _acp_indentPrep = max (_acp_indentPrep acp) indAdd }
|
||||||
let indAdd = case indent of
|
|
||||||
BrIndentNone -> 0
|
|
||||||
BrIndentRegular -> indAmount
|
|
||||||
BrIndentSpecial i -> i
|
|
||||||
let indAdd' =
|
|
||||||
if indPolicy == IndentPolicyMultiple
|
|
||||||
then
|
|
||||||
max 0 (indAdd - ((_acp_indent acp + indAdd) `mod` indAmount))
|
|
||||||
else indAdd
|
|
||||||
mSet $ acp { _acp_indentPrep = max (_acp_indentPrep acp) indAdd' }
|
|
||||||
r <- rec bd
|
r <- rec bd
|
||||||
acp' <- mGet
|
acp' <- mGet
|
||||||
mSet $ acp' { _acp_indent = _acp_indent acp }
|
mSet $ acp' { _acp_indent = _acp_indent acp }
|
||||||
return $ case indent of
|
return $ case indent of
|
||||||
BrIndentNone -> r
|
BrIndentNone -> r
|
||||||
BrIndentRegular -> reWrap $ BDFAddBaseY (BrIndentSpecial indAdd') r
|
BrIndentRegular -> reWrap $ BDFAddBaseY (BrIndentSpecial indAdd) r
|
||||||
BrIndentSpecial i -> reWrap $ BDFAddBaseY (BrIndentSpecial i) r
|
BrIndentSpecial i -> reWrap $ BDFAddBaseY (BrIndentSpecial i) r
|
||||||
BDFBaseYPushCur bd -> do
|
BDFBaseYPushCur bd -> do
|
||||||
acp <- mGet
|
acp <- mGet
|
||||||
|
@ -321,11 +311,7 @@ transformAlts =
|
||||||
return $ reWrap $ BDFLines (l':lr')
|
return $ reWrap $ BDFLines (l':lr')
|
||||||
BDFEnsureIndent indent bd -> do
|
BDFEnsureIndent indent bd -> do
|
||||||
acp <- mGet
|
acp <- mGet
|
||||||
indAmount <- mAsk <&> _conf_layout .> _lconfig_indentAmount .> confUnpack
|
indAdd <- fixIndentationForMultiple acp indent
|
||||||
let indAdd = case indent of
|
|
||||||
BrIndentNone -> 0
|
|
||||||
BrIndentRegular -> indAmount
|
|
||||||
BrIndentSpecial i -> i
|
|
||||||
mSet $ acp
|
mSet $ acp
|
||||||
{ _acp_indentPrep = 0
|
{ _acp_indentPrep = 0
|
||||||
-- TODO: i am not sure this is valid, in general.
|
-- TODO: i am not sure this is valid, in general.
|
||||||
|
@ -863,3 +849,25 @@ getSpacings limit bridoc = preFilterLimit <$> rec bridoc
|
||||||
VerticalSpacingParSome i -> VerticalSpacingParSome $ x1 `max` i
|
VerticalSpacingParSome i -> VerticalSpacingParSome $ x1 `max` i
|
||||||
VerticalSpacingParNone -> VerticalSpacingParSome $ x1
|
VerticalSpacingParNone -> VerticalSpacingParSome $ x1
|
||||||
VerticalSpacingParAlways i -> VerticalSpacingParAlways $ x1 `max` i
|
VerticalSpacingParAlways i -> VerticalSpacingParAlways $ x1 `max` i
|
||||||
|
|
||||||
|
fixIndentationForMultiple
|
||||||
|
:: (MonadMultiReader (CConfig Identity) m) => AltCurPos -> BrIndent -> m Int
|
||||||
|
fixIndentationForMultiple acp indent = do
|
||||||
|
indAmount <- mAsk <&> _conf_layout .> _lconfig_indentAmount .> confUnpack
|
||||||
|
let indAddRaw = case indent of
|
||||||
|
BrIndentNone -> 0
|
||||||
|
BrIndentRegular -> indAmount
|
||||||
|
BrIndentSpecial i -> i
|
||||||
|
-- for IndentPolicyMultiple, we restrict the amount of added
|
||||||
|
-- indentation in such a manner that we end up on a multiple of the
|
||||||
|
-- base indentation.
|
||||||
|
indPolicy <- mAsk <&> _conf_layout .> _lconfig_indentPolicy .> confUnpack
|
||||||
|
pure $ if indPolicy == IndentPolicyMultiple
|
||||||
|
then
|
||||||
|
let indAddMultiple1 =
|
||||||
|
indAddRaw - ((_acp_indent acp + indAddRaw) `mod` indAmount)
|
||||||
|
indAddMultiple2 = if indAddMultiple1 <= 0
|
||||||
|
then indAddMultiple1 + indAmount
|
||||||
|
else indAddMultiple1
|
||||||
|
in indAddMultiple2
|
||||||
|
else indAddRaw
|
||||||
|
|
Loading…
Reference in New Issue