Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 02cef7f

Browse files
committed
Fix Ormolu removing preceding empty line
1 parent 4a13f87 commit 02cef7f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Haskell/Ide/Engine/Plugin/Ormolu.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,12 @@ provider contents uri typ _ = pluginGetFile contents uri $ \fp -> do
7979
txt = T.lines $ extractRange r contents
8080
lineRange (Range (Position sl _) (Position el _)) =
8181
Range (Position sl 0) $ Position el $ T.length $ last txt
82-
fixLine t = if T.all isSpace $ last txt then t else T.init t
82+
hIsSpace (h : _) = T.all isSpace h
83+
hIsSpace _ = True
84+
fixS t = if hIsSpace txt && (not $ hIsSpace t) then "" : t else t
85+
fixE t = if T.all isSpace $ last txt then t else T.init t
8386
unStrip ws new =
84-
fixLine $ T.unlines $ map (ws `T.append`) $ T.lines new
87+
fixE $ T.unlines $ map (ws `T.append`) $ fixS $ T.lines new
8588
mStrip = case txt of
8689
(l : _) ->
8790
let ws = fst $ T.span isSpace l

0 commit comments

Comments
 (0)