diff options
author | Artyom <yom@artyom.me> | 2017-04-17 18:12:57 +0300 |
---|---|---|
committer | Artyom <yom@artyom.me> | 2017-04-17 18:12:57 +0300 |
commit | 39421b3836a44489bcc56cd08c75c09ee70c5a69 (patch) | |
tree | 8602029036b43f266d9c60a733957459cf065f0a | |
parent | b43f4721f6ec2799cbcd3acdbc41c05e91b2bd42 (diff) | |
download | stylish-haskell-39421b3836a44489bcc56cd08c75c09ee70c5a69.tar.gz |
Don't leave #-} hanging
Fixes #154
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | lib/Language/Haskell/Stylish/Step/LanguagePragmas.hs | 2 | ||||
-rw-r--r-- | tests/Language/Haskell/Stylish/Step/LanguagePragmas/Tests.hs | 30 |
3 files changed, 33 insertions, 1 deletions
@@ -3,6 +3,8 @@ - next * Remove `MagicHash` from whitelisted language extensions, since it was causing parsing errors + * Don't leave a `#-}` hanging on the next line when `language_pragmas` + is set to `compact` and the `#-}` doesn't fit into character limit - 0.7.1.0 * Keep `safe` and `{-# SOURCE #-}` import annotations (by Moritz Drexl) diff --git a/lib/Language/Haskell/Stylish/Step/LanguagePragmas.hs b/lib/Language/Haskell/Stylish/Step/LanguagePragmas.hs index c63d90a..cdedfa8 100644 --- a/lib/Language/Haskell/Stylish/Step/LanguagePragmas.hs +++ b/lib/Language/Haskell/Stylish/Step/LanguagePragmas.hs @@ -56,7 +56,7 @@ verticalPragmas longest align pragmas' = -------------------------------------------------------------------------------- compactPragmas :: Int -> [String] -> Lines compactPragmas columns pragmas' = wrap columns "{-# LANGUAGE" 13 $ - map (++ ",") (init pragmas') ++ [last pragmas', "#-}"] + map (++ ",") (init pragmas') ++ [last pragmas' ++ " #-}"] -------------------------------------------------------------------------------- diff --git a/tests/Language/Haskell/Stylish/Step/LanguagePragmas/Tests.hs b/tests/Language/Haskell/Stylish/Step/LanguagePragmas/Tests.hs index fe889e4..2d74813 100644 --- a/tests/Language/Haskell/Stylish/Step/LanguagePragmas/Tests.hs +++ b/tests/Language/Haskell/Stylish/Step/LanguagePragmas/Tests.hs @@ -26,6 +26,8 @@ tests = testGroup "Language.Haskell.Stylish.Step.LanguagePragmas.Tests" , testCase "case 06" case06 , testCase "case 07" case07 , testCase "case 08" case08 + , testCase "case 09" case09 + , testCase "case 10" case10 ] @@ -167,3 +169,31 @@ case08 = expected @=? testStep (step 80 CompactLine False False) input "TemplateHaskell #-}" , "{-# LANGUAGE TypeOperators, ViewPatterns #-}" ] + + +-------------------------------------------------------------------------------- +case09 :: Assertion +case09 = expected @=? testStep (step 80 Compact True False) input + where + input = unlines + [ "{-# LANGUAGE DefaultSignatures, FlexibleInstances, LambdaCase, " ++ + "TypeApplications" + , " #-}" + ] + expected = unlines + [ "{-# LANGUAGE DefaultSignatures, FlexibleInstances, LambdaCase," + , " TypeApplications #-}" + ] + +-------------------------------------------------------------------------------- +case10 :: Assertion +case10 = expected @=? testStep (step 80 Compact True False) input + where + input = unlines + [ "{-# LANGUAGE NondecreasingIndentation, ScopedTypeVariables," + , " TypeApplications #-}" + ] + expected = unlines + [ "{-# LANGUAGE NondecreasingIndentation, ScopedTypeVariables, " ++ + "TypeApplications #-}" + ] |