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

Add line length limit which includes indentation #288

Open
CobaltCause opened this issue Mar 2, 2025 · 1 comment
Open

Add line length limit which includes indentation #288

CobaltCause opened this issue Mar 2, 2025 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@CobaltCause
Copy link

CobaltCause commented Mar 2, 2025

Description

The input is 81 columns wide. If I use --width 80, the output is the same as the input. If I incrementally decrease the width by one character, I find the output does eventually get reflowed at --width 76.

I experienced this on 187985f.

Small example input

    sprinkles = if sprinkles == null then import source.sprinkles else sprinkles;

Expected output

I personally prefer this, but I would also accept the output given with --width 76 which is shown later.

    sprinkles = if sprinkles == null
      then import source.sprinkles
      else sprinkles;

Actual output

At 80 columns:

    sprinkles = if sprinkles == null then import source.sprinkles else sprinkles;

At 76 columns:

    sprinkles =
      if sprinkles == null then import source.sprinkles else sprinkles;
@CobaltCause CobaltCause changed the title --width not respected in long if expression --width not respected in long if expression Mar 2, 2025
@piegamesde
Copy link
Member

Nixfmt currently does not include the preceding whitespace in the maximum line length calculation. That is intended behavior, it was once planned to add another flag to configure this but if never got implemented.

@piegamesde piegamesde changed the title --width not respected in long if expression Add line length limit which includes indentation Mar 2, 2025
@piegamesde piegamesde added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Mar 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
Status: Todo
Development

No branches or pull requests

2 participants