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

Interesting comment placements in various scenarios #1074

Open
LiamGoodacre opened this issue Nov 9, 2023 · 1 comment
Open

Interesting comment placements in various scenarios #1074

LiamGoodacre opened this issue Nov 9, 2023 · 1 comment
Labels
comments Issues related to comment placement style Nitpicking and things related to purely visual aspect for formatting.

Comments

@LiamGoodacre
Copy link

Describe the bug

Here are a bunch of strange comment placements that I've noticed.

To Reproduce

Positive example

This one looks good

Input, & Output

example =
  [ -- A
    [], -- B
    -- C
    [] -- D
    -- E
  ] -- F

Using QQ in the previous example

Input (& expected output)

example =
  [ -- A
    [u||], -- B
    -- C
    [u||] -- D
    -- E
  ] -- F

Output

example =
  [ -- A
    [u||],
    -- B
    -- C
    [u||]
  ]

-- D
-- E
-- F

Record with comment on each line

Input (& expected output)

example =
  Record
    { -- A
      field = (), -- B
      -- C
      field = (), -- D
      -- E
      .. -- F
    } -- G

Output

example =
  Record
    { -- A
      field = (), -- B
      -- C
      field = (), -- D
      -- E
      ..
    }

-- F
-- G

Records with fewer comments

Notice how -- E here is also moved, which differs from the previous example.

Input (& expected output)

example =
  Record
    { -- A
      field = (),
      -- C
      field = (),
      -- E
      .. -- F
    } -- G

Output

example =
  Record
    { -- A
      field = (),
      -- C
      field = (),
      ..
    }

-- E
-- F
-- G

Environment

@amesgen amesgen added style Nitpicking and things related to purely visual aspect for formatting. comments Issues related to comment placement labels Nov 9, 2023
@LiamGoodacre
Copy link
Author

Comment in import lists

It looks like ormolu interprets the comment as relating to the import Example3 line.

Input (& expected output)

import Example1
import Example2 ({- comment -})
import Example3

Output

import Example1
import Example2 ()
{- comment -}
import Example3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comments Issues related to comment placement style Nitpicking and things related to purely visual aspect for formatting.
Projects
None yet
Development

No branches or pull requests

2 participants