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

Weird formatting of optionals #278

Open
jtojnar opened this issue Jan 24, 2025 · 0 comments
Open

Weird formatting of optionals #278

jtojnar opened this issue Jan 24, 2025 · 0 comments

Comments

@jtojnar
Copy link
Member

jtojnar commented Jan 24, 2025

Description

When formatting a long line with condition and a list, splitting the condition is preferred over the list. Would be nice to have some heuristic that would prefer the opposite.

Small example input

{
  NIX_CFLAGS_COMPILE = lib.optionals (lib.versionOlder prev.php.version "7.2" && pkgs.stdenv.cc.isClang) [" -Wno-implicit-int"];
}

Expected output

{
  NIX_CFLAGS_COMPILE =
    lib.optionals (lib.versionOlder prev.php.version "7.2" && pkgs.stdenv.cc.isClang)
      [
        " -Wno-implicit-int"
      ];
}

Actual output

{
  NIX_CFLAGS_COMPILE = lib.optionals (
    lib.versionOlder prev.php.version "7.2" && pkgs.stdenv.cc.isClang
  ) [ " -Wno-implicit-int" ];
}

I can get the preferred formatting if I split the array onto multiple lines. For example

{
  NIX_CFLAGS_COMPILE = lib.optionals (lib.versionOlder prev.php.version "7.2" && pkgs.stdenv.cc.isClang) [" -Wno-implicit-int"
  ];
}```
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