From d4f49f9ced7cf7e7a3cf359410b946a5b217cab4 Mon Sep 17 00:00:00 2001 From: Lennart Spitzner Date: Mon, 22 May 2023 16:50:35 +0200 Subject: [PATCH] Fix one more block-comment restore-position issue --- data/15-regressions.blt | 8 ++++++++ .../Haskell/Brittany/Internal/WriteBriDoc/Operators.hs | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/data/15-regressions.blt b/data/15-regressions.blt index 4c43e3d..ae922ff 100644 --- a/data/15-regressions.blt +++ b/data/15-regressions.blt @@ -1043,3 +1043,11 @@ duGswidunBlxaq drux = DeeX.Vufcqqafi | otherwise -> Likiotq ) + +#test multiline-block-comment in do-block +func = do + abc + {- some long + block comment -} + x <- readLine + print x diff --git a/source/library/Language/Haskell/Brittany/Internal/WriteBriDoc/Operators.hs b/source/library/Language/Haskell/Brittany/Internal/WriteBriDoc/Operators.hs index d61a306..354d4d6 100644 --- a/source/library/Language/Haskell/Brittany/Internal/WriteBriDoc/Operators.hs +++ b/source/library/Language/Haskell/Brittany/Internal/WriteBriDoc/Operators.hs @@ -25,6 +25,7 @@ where import Language.Haskell.Brittany.Internal.Prelude +import qualified Data.Maybe import qualified Data.Text as Text import qualified Data.Text.Lazy.Builder as Text.Builder import qualified GHC.OldList as List @@ -157,7 +158,9 @@ layoutWriteComment absolute isBlock dp commentLines s = do -- TODO92 we don't mo PlannedNewline l -> if l <= y then PlannedSameline 1 else PlannedNewline (l - y) PlannedDelta l i -> - if l <= y then PlannedSameline 1 else PlannedDelta (l - y) i + if l <= y && Data.Maybe.isNothing (_lstate_markerForDelta state) + then PlannedSameline 1 + else PlannedDelta (l - y) i else case _lstate_plannedSpace state of PlannedNone -> PlannedDelta 1 (_lstate_curY state) PlannedSameline i -> PlannedDelta 1 (_lstate_curY state + i)