Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing comment inhibits a following empty line #1132

Open
ChickenProp opened this issue Sep 4, 2024 · 0 comments
Open

Trailing comment inhibits a following empty line #1132

ChickenProp opened this issue Sep 4, 2024 · 0 comments
Labels
style Nitpicking and things related to purely visual aspect for formatting.

Comments

@ChickenProp
Copy link

Describe the bug

In layout mode (i.e. where, do, let), empty lines between blocks of code are optional. But if one block ends with a trailing comment on its final line, then an empty line before the next block is removed.

To Reproduce

The blank lines between the a and b lines in this snippet are removed.

test1 = foo where
  a = a --
  
  b = b
    
test2 = do
  a --
  
  b

test3 = let a = a --

            b = b
        in c

This also happens if the comment includes text (a = a -- foo), or if it's a block comment with nothing after it (a = a {- foo -}), or if there's another comment on the next line. It doesn't happen if the comment is on the next line without one on the current line, or if the expression continues on the next line, or if it's a block comment with something following (a = a {- foo -} 1). (A block comment with newlines has the same behavior as one without.) Also, it doesn't happen if the following block starts with a comment, as long as it does have a newline before it. That is:

-- all these blank lines are preserved
test4 = do
  a --
  
  --
  
  bar

-- this one is removed
test5 = do
  a --
  --
  
  bar

Expected behavior

I'd expect all these blank lines to be preserved

Environment

Tested on the web at https://ormolu-live.tweag.io/. Version 0.7.7.0, commit 392b2bc, using ghc-lib-parser 9.10.1.20240511.

@amesgen amesgen added the style Nitpicking and things related to purely visual aspect for formatting. label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
style Nitpicking and things related to purely visual aspect for formatting.
Projects
None yet
Development

No branches or pull requests

2 participants