File tree Expand file tree Collapse file tree
data/examples/declaration/value/function Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515* Correctly format string literals containing the ` \^\ ` escape sequence. [ Issue
1616 1165] ( https://github.com/tweag/ormolu/issues/1165 ) .
1717
18+ * Correctly preserve consecutive blank lines in multiline strings. [ Issue
19+ 1194] ( https://github.com/tweag/ormolu/issues/1194 ) .
20+
1821## Ormolu 0.8.0.2
1922
2023* Fixed a performance regression introduced in 0.8.0.0. [ Issue
Original file line number Diff line number Diff line change 1+ {-# LANGUAGE MultilineStrings #-}
2+
3+ multilineBlank =
4+ " " "
5+ 1
6+
7+
8+
9+
10+ 6
11+ " " "
Original file line number Diff line number Diff line change 1+ {-# LANGUAGE MultilineStrings #-}
2+
3+ multilineBlank =
4+ " " "
5+ 1
6+
7+
8+
9+
10+ 6
11+ " " "
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ module Ormolu.Printer.Combinators
2121 atom ,
2222 space ,
2323 newline ,
24+ newlineLiteral ,
2425 inci ,
2526 inciIf ,
2627 askSourceType ,
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ module Ormolu.Printer.Internal
1717 atom ,
1818 space ,
1919 newline ,
20+ newlineLiteral ,
2021 askSourceType ,
2122 askModuleFixityMap ,
2223 askDebug ,
@@ -386,6 +387,19 @@ newlineRaw = R . modify $ \sc ->
386387 _ -> AfterNewline
387388 }
388389
390+ -- | Insert a newline literal without modifying the internal state of the
391+ -- parser. This is to be used exceptionally, e.g. for printing multiline
392+ -- string literals.
393+ newlineLiteral :: R ()
394+ newlineLiteral = R . modify $ \ sc ->
395+ sc
396+ { scBuilder = scBuilder sc <> " \n " ,
397+ scColumn = 0 ,
398+ scIndent = 0 ,
399+ scThisLineSpans = [] ,
400+ scRequestedDelimiter = AfterNewline
401+ }
402+
389403-- | Return the source type.
390404askSourceType :: R SourceType
391405askSourceType = R (asks rcSourceType)
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ p_stringLit src = case parseStringLiteral $ T.pack $ unpackFS src of
4040 LastPos -> txt " \\ " *> txt s
4141 vlayout singleLine multiLine
4242 MultilineStringLiteral ->
43- sep breakpoint' txt segments
43+ sep newlineLiteral txt segments
4444 txt endMarker
4545
4646-- | The start/end marker of the literal, whether it is a regular or a multiline
You can’t perform that action at this time.
0 commit comments