diff --git a/src/Dhall/Core.hs b/src/Dhall/Core.hs index 8cf046a..bdfaafa 100644 --- a/src/Dhall/Core.hs +++ b/src/Dhall/Core.hs @@ -180,19 +180,18 @@ instance Semigroup ImportType where instance Buildable ImportType where build (Local prefix file) = - build prefix <> build file <> " " + build prefix <> build file build (URL prefix file suffix headers) = build prefix <> build file <> build suffix <> foldMap buildHeaders headers - <> " " where buildHeaders h = " using " <> build h build (Env env) = - "env:" <> build env <> " " + "env:" <> build env -- | How to interpret the import's contents (i.e. as Dhall code or raw text) data ImportMode = Code | RawText deriving (Eq, Ord, Show) diff --git a/tests/Format.hs b/tests/Format.hs index f45a0c9..bb56e59 100644 --- a/tests/Format.hs +++ b/tests/Format.hs @@ -39,6 +39,12 @@ formatTests = , should "indent then/else to the same column" "ifThenElse" + , should + "handle indenting long imports correctly without trailing space per line" + "importLines" + , should + "handle indenting small imports correctly without trailing space inline" + "importLines2" ] opts :: Data.Text.Prettyprint.Doc.LayoutOptions diff --git a/tests/format/importLines2A.dhall b/tests/format/importLines2A.dhall new file mode 100644 index 0000000..b8c0457 --- /dev/null +++ b/tests/format/importLines2A.dhall @@ -0,0 +1,2 @@ +let _ = ./emptyRecordA.dhall +in let _ = ./emptyRecordA.dhall in 123 \ No newline at end of file diff --git a/tests/format/importLines2B.dhall b/tests/format/importLines2B.dhall new file mode 100644 index 0000000..512e762 --- /dev/null +++ b/tests/format/importLines2B.dhall @@ -0,0 +1 @@ +let _ = ./emptyRecordA.dhall in let _ = ./emptyRecordA.dhall in 123 \ No newline at end of file diff --git a/tests/format/importLinesA.dhall b/tests/format/importLinesA.dhall new file mode 100644 index 0000000..572cfc6 --- /dev/null +++ b/tests/format/importLinesA.dhall @@ -0,0 +1,7 @@ +let _ = ./emptyRecordA.dhall +in let _ = ./emptyRecordA.dhall +in let _ = ./emptyRecordA.dhall +in let _ = ./emptyRecordA.dhall +in let _ = ./emptyRecordA.dhall +in let _ = ./emptyRecordA.dhall +in 123 diff --git a/tests/format/importLinesB.dhall b/tests/format/importLinesB.dhall new file mode 100644 index 0000000..e9a4935 --- /dev/null +++ b/tests/format/importLinesB.dhall @@ -0,0 +1,13 @@ + let _ = ./emptyRecordA.dhall + +in let _ = ./emptyRecordA.dhall + +in let _ = ./emptyRecordA.dhall + +in let _ = ./emptyRecordA.dhall + +in let _ = ./emptyRecordA.dhall + +in let _ = ./emptyRecordA.dhall + +in 123 \ No newline at end of file