Skip to content

Commit

Permalink
0.19 upgrade: keep all comments when upgrading Html.Attributes.style
Browse files Browse the repository at this point in the history
  • Loading branch information
avh4 committed May 17, 2018
1 parent 49f52e9 commit e7e7757
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ElmFormat/Upgrade_0_19.hs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ expandHtmlStyle styleExposed importAlias (preComma, (pre, (term, eol))) =
_ -> False
in
case RA.drop term of
App (A _ (VarExpr var)) [(xx, A _ (ExplicitList styles trailing multiline))] _ | isHtmlAttributesStyle var ->
fmap (\(preComma', (pre', (style, eol'))) -> (preComma', (pre', (applyLambda (noRegion $ lambda var) [([], style)] (FAJoinFirst JoinAll), eol')))) styles
App (A _ (VarExpr var)) [(preStyle, A _ (ExplicitList styles trailing _))] _ | isHtmlAttributesStyle var ->
fmap (\(preComma', (pre', (style, eol'))) -> (preComma ++ preComma', (pre ++ preStyle ++ pre' ++ trailing ++ (Maybe.maybeToList $ fmap LineComment eol), (applyLambda (noRegion $ lambda var) [([], style)] (FAJoinFirst JoinAll), eol')))) styles

_ ->
[(preComma, (pre, (term, eol)))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ convertsStyle = Html.div [Html.Attributes.style [("a", "1")]] []
convertsExposedStyle = Html.div [style [("a", "1")]] []

doesntConvertOtherFunctions f = Html.div [ f [("a", "1")] ] []

comments = Html.div{-A-}[{-B-}style{-C-}[{-D-}({-E-}"a"{-F-},{-G-}"1"{-H-}){-I-},{-J-}({-K-}"b"{-L-},{-M-}"2"{-N-}){-O-}]{-P-}]{-Q-}[]
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,16 @@ convertsExposedStyle =

doesntConvertOtherFunctions f =
Html.div [ f [ ( "a", "1" ) ] ] []


comments =
Html.div
{- A -}
[ {- B -} {- C -} {- D -} {- O -} style ({- E -} "a" {- F -}) ({- G -} "1" {- H -})

{- I -}
, {- B -} {- C -} {- J -} {- O -} style ({- K -} "b" {- L -}) ({- M -} "2" {- N -})

{- P -}
]
{- Q -} []

0 comments on commit e7e7757

Please sign in to comment.