Skip to content

strings are absorbed when they are split onto multiple lines #281

@Atemu

Description

@Atemu

Description

When a string has a long interpolation, the string gets split onto multiple lines but when this is done, the string is still absorbed. The trivial case with just one oversized interpolation (see examples) is technically legal under the RFC style as only the first and last line are not indented. This looks very odd however and is different to how function arguments are handled which have a similar problem of trailing content behind an otherwise absorbable term.

nixfmt will however also not indent intermediate interpolations ends which is definitely not legal. It also doesn't matter whether it's a single-line or multi-line string.

    changelog = ''https://gitlab.freedesktop.org/freetype/freetype/-/raw/VER-${
      builtins.replaceStrings [ "." ] [ "-" ] finalAttrs.version
    }/docs/${
      builtins.replaceStrings [ "." ] [ "-" ] finalAttrs.versionloooooooooooooooooooooooooooooooooong
    }CHANGES'';

When a string is split onto multiple lines for whatever reason, we should probably just always not absorb which is in line with how function arguments work.

Small example input

https://github.com/NixOS/nixpkgs/blob/29cda11adc0a21c51009073caca26ea10e506071/pkgs/by-name/fr/freetype/package.nix#L140-L142

    changelog = "https://gitlab.freedesktop.org/freetype/freetype/-/raw/VER-${builtins.replaceStrings [ "." ] [ "-" ] finalAttrs.version}/docs/CHANGES";

Expected output

    changelog =
      "https://gitlab.freedesktop.org/freetype/freetype/-/raw/VER-${
        builtins.replaceStrings [ "." ] [ "-" ] finalAttrs.version
      }/docs/CHANGES";

Actual output

    changelog = "https://gitlab.freedesktop.org/freetype/freetype/-/raw/VER-${
      builtins.replaceStrings [ "." ] [ "-" ] finalAttrs.version
    }/docs/CHANGES";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions