Skip to content

Commit

Permalink
Fix NixOS#188
Browse files Browse the repository at this point in the history
Fixes NixOS#188
  • Loading branch information
piegamesde committed Apr 15, 2024
1 parent 35b0186 commit e234c2b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Nixfmt/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Nixfmt.Types
ParamAttr(..), Parameter(..), Selector(..), SimpleSelector(..),
StringPart(..), Term(..), Token(..), TrailingComment(..), Trivium(..),
Whole(..), tokenText, mapFirstToken, mapFirstToken', mapLastToken', hasTrivia)
-- import Debug.Trace (traceShowId)

toLineComment :: TrailingComment -> Trivium
toLineComment (TrailingComment c) = LineComment $ " " <> c
Expand Down Expand Up @@ -60,6 +61,8 @@ prettyItems sep items = prettyItems' $ unItems items
prettyItems' :: Pretty a => [Item a] -> Doc
prettyItems' [] = mempty
prettyItems' [item] = pretty item
-- Fix for https://github.com/NixOS/nixfmt/issues/188
prettyItems' [item, DetachedComments []] = pretty item
prettyItems' (item : xs)
= pretty item
<> case item of { CommentedItem _ _ -> sep; DetachedComments _ -> emptyline }
Expand Down

0 comments on commit e234c2b

Please sign in to comment.