Skip to content

Formatter fix: next_break_fits respects line_length #13792

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

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

sabiwara
Copy link
Contributor

Tentative fix for #13775

The problem is that the closing bracket ")" is ignored when evaluating the nested group for which fitting is enabled.

["f" · disable([
  ²⟨"(" · _⟩ · ²⟨enable([
    ²⟨"%" · ∅ · "{" · _ · ["x"]⟩ · _ · "}"
  ])⟩ · _ · ")" · ∅
])]

The approach:

  • fits? doesn't return a bool anymore, but :fit | :no_fit | :break_next, :break_next meaning that we wouldn't actually fit without breaking within the nested :enabled
  • add more modes to format to make sure we break in the nested :enabled

@josevalim
Copy link
Member

@sabiwara I need to dig deeper but can we break this PR or this commit in two? One that goes from boolean to :fit | :no_fit and another one with the fix? This will make it easier to assess the impact of the change. :)

@sabiwara
Copy link
Contributor Author

can we break this PR or this commit in two? One that goes from boolean to :fit | :no_fit and another one with the fix?

Of course! Sorry the diff wasn't very readable indeed.

I need to dig deeper

Yes this is a tricky one and my confidence is not great, I'm just starting to understand how the whole fitting works.

@sabiwara
Copy link
Contributor Author

@josevalim should be much better 😌 d40b032

Copy link
Member

@josevalim josevalim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me! Thank you for working on this. ❤️

@sabiwara sabiwara merged commit 8cb6abf into elixir-lang:main Sep 18, 2024
9 checks passed
@sabiwara sabiwara deleted the fmt-break-no-flat branch September 18, 2024 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants