Skip to content

Preserve more trailing comments #323

@jfly

Description

@jfly

Today, we sometimes allow trailing comments, and sometimes move them to the next line. For example:

Input:

foo = { # this should be an SSID
}

Current output:

foo = {
  # this should be an SSID
}

Requested output:

# this should be an SSID
foo = {
}

We discussed this at today's team meeting, and agreed that we'd like to preserve more of these.

See this commit for context: NixOS/nixpkgs@0f3f710

Originally reported below:

Maybe there is a strong argument for assuming the comment should usually go above instead of below?

I'd argue:

  • A comment at the end of the line is always about that line.
  • Comments on separate lines should usually go before the thing that they concern.

There are probably edge-cases where just moving the comment to the next line is the right thing... but my guess is that the majority of cases is better handled by moving them to the previous line instead.

Originally posted by @wolfgangwalther in NixOS/nixpkgs#427460 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Approved

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions