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

Comments in inherits have extra newlines inserted. #407

Open
bakhtiyarneyman opened this issue Feb 20, 2024 · 4 comments
Open

Comments in inherits have extra newlines inserted. #407

bakhtiyarneyman opened this issue Feb 20, 2024 · 4 comments
Labels
component | style Modifications to the formatting rules good first issue Good for newcomers help wanted Extra attention is needed status | it is a good thing We agree it is good to implement this type | bug Something isn't working

Comments

@bakhtiyarneyman
Copy link

paths = builtins.attrValues {
  inherit
    (pkgs)
    foo
    # This comment was supposed to be attached to bar.
    
    # But it gets split like this.
    
    bar
    baz
}
@bakhtiyarneyman bakhtiyarneyman changed the title Multiline comments in inherits have extra newlines inserted. Comments in inherits have extra newlines inserted. Feb 20, 2024
@yajo
Copy link

yajo commented Apr 15, 2024

Besides the extra newlines, those lines are full of white spaces.

@xceral
Copy link

xceral commented May 26, 2024

This happens with any trailing comment inside an expression:

{
  a = assert true; #
__
    1;
  b =
    foo #
____
    bar;
}

(superfluous spaces replaced with underscores for clarification)

@ShamrockLee
Copy link

I just experienced this issue.

@kamadorueda
Copy link
Owner

Perhaps this was fixed in 3.1.0?

https://kamadorueda.com/alejandra/?before=%7Bpaths+%3D+builtins.attrValues+%7B%0A++inherit%0A++++%28pkgs%29%0A++++foo%0A++++%23+This+comment+was+supposed+to+be+attached+to+bar.%0A++++%23+But+it+gets+split+like+this.%0A++++bar%0A++++baz%3B%0A%7D%3B%7D

Before:

{paths = builtins.attrValues {
  inherit
    (pkgs)
    foo
    # This comment was supposed to be attached to bar.
    # But it gets split like this.
    bar
    baz;
};}

After

{
  paths = builtins.attrValues {
    inherit
      (pkgs)
      foo
      # This comment was supposed to be attached to bar.
      # But it gets split like this.
      bar
      baz
      ;
  };
}

@kamadorueda kamadorueda added type | bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers component | style Modifications to the formatting rules status | it is a good thing We agree it is good to implement this labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component | style Modifications to the formatting rules good first issue Good for newcomers help wanted Extra attention is needed status | it is a good thing We agree it is good to implement this type | bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants