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

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

Open
Atemu opened this issue Feb 12, 2025 · 0 comments
Open

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

Atemu opened this issue Feb 12, 2025 · 0 comments

Comments

@Atemu
Copy link
Member

Atemu commented Feb 12, 2025

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";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

1 participant