Skip to content

Whitepace added around parentheses within string #399

@n8henrie

Description

@n8henrie

I have a "line too long" error thrown by pkgs.writers.writePythonApplication that I'm working around by changing

''"${thisLongNixPath}"'' into

''(
        "${thisLongNixPath}"
)';'

as the newline break should put the long string under the line length limit.

Unfortunately, alejandra keeps adding a bunch of whitespace before the ( and the "${:

$ diff flake.nix <(alejandra -q <flake.nix )
35,37c35,37
<           ''(
<             "${chromium}/Chromium.app/Contents/MacOS/Chromium"
<             )
---
>           ''            (
>                         "${chromium}/Chromium.app/Contents/MacOS/Chromium"
>                         )

I think that's because this is surrounded in a square bracket, and it seems to want to align the inner parentheses to the outer square bracket, but this kind of alignment within a string perhaps shouldn't happen:

Pre:

        replacements = [
          "--replace"
          ''"./Chromium.app/Contents/MacOS/Chromium"''
          ''(
            "${chromium}/Chromium.app/Contents/MacOS/Chromium"
            )
          ''
        ];

Post:

        replacements = [
          "--replace"
          ''"./Chromium.app/Contents/MacOS/Chromium"''
          ''            (
                        "${chromium}/Chromium.app/Contents/MacOS/Chromium"
                        )
          ''
        ];

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions