Skip to content

Commented lines in a collection are deleted #168

@casedami

Description

@casedami

Describe the bug

In a multi line collection, if some lines are comments then they get deleted after format.

let a = {
  my_key: "my_key"
  # a comment
  my_other_key: "my_other_key"
}

# becomes

let a = {
  my_key: "my_key"
  my_other_key: "my_other_key"
}

Steps to reproduce

  1. run on nufmt 0.1.0

Expected behavior

The comments should be preserved

Environment

Please run rustc --version and paste the result.

[user@system:~]$ rustc --version
rustc 1.95.0 (59807616e 2026-04-14)

If using Nix please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
output here

Notify maintainers

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions