diff --git a/packages.dhall b/packages.dhall index 3546298..7697066 100644 --- a/packages.dhall +++ b/packages.dhall @@ -39,4 +39,4 @@ in upstream } with language-cst-parser = - (upstream.language-cst-parser with version = "v0.13.0") + (upstream.language-cst-parser with version = "v0.14.0") diff --git a/src/Tidy.purs b/src/Tidy.purs index 59537cb..72361be 100644 --- a/src/Tidy.purs +++ b/src/Tidy.purs @@ -120,7 +120,8 @@ instance formatErrorRecoveredError :: FormatError RecoveredError where goComments :: forall a b. Int -> { line :: Boolean, doc :: Dodo.Doc b } -> Comment a -> { line :: Boolean, doc :: Dodo.Doc b } goComments ind acc = case _ of Comment str - | SCU.take 2 str == "--" -> + | leading <- SCU.take 2 str + , leading == "--" || leading == "#!" -> { line: false, doc: acc.doc <> Dodo.text str } | otherwise -> { line: false, doc: acc.doc <> Dodo.lines (Dodo.text <$> splitLines str) } @@ -145,7 +146,8 @@ formatComment -> FormatDoc a formatComment lineComment blockComment com next = case com of Comment str - | SCU.take 2 str == "--" -> + | leading <- SCU.take 2 str + , leading == "--" || leading == "#!" -> lineComment str next | otherwise -> blockComment str next diff --git a/test/snapshots/Shebang.output b/test/snapshots/Shebang.output new file mode 100644 index 0000000..38ffca6 --- /dev/null +++ b/test/snapshots/Shebang.output @@ -0,0 +1,4 @@ +#! shebang 1 +#! shebang 2 +-- comment +module Foo.Bar where diff --git a/test/snapshots/Shebang.purs b/test/snapshots/Shebang.purs new file mode 100644 index 0000000..38ffca6 --- /dev/null +++ b/test/snapshots/Shebang.purs @@ -0,0 +1,4 @@ +#! shebang 1 +#! shebang 2 +-- comment +module Foo.Bar where