Skip to content

Prettier converts blocks with a long single line from do...end to {...} #1346

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

Closed
varg90 opened this issue May 26, 2023 · 1 comment
Closed

Comments

@varg90
Copy link

varg90 commented May 26, 2023

Hello!

What
Prettier converts this code

if filtered_codes.any? { |codes| codes.include?(code) || (codes.starts_with?('2') && codes.include?(code[0..-6])) }
...

into this because of the printWidth

if filtered_codes.any? { |codes| 
  codes.include?(code) || (codes.starts_with?('2') && codes.include?(code[0..-6]))
}
...

and for some reason thinks that this block is still a single-line and force {..} instead of do...end.

Expected
Either

if filtered_codes.any? { |codes| short_line }

or

if filtered_codes.any? do |codes|
  really_long_lineeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
end

Actual

if filtered_codes.any? { |codes| 
  really_long_lineeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
}

Versions
npm:
prettier (2.8.8)
@prettier/plugin-ruby (3.2.2)
gems:
prettier_print (1.2.1)
syntax_tree (6.1.1)
syntax_tree-haml (4.0.3)
syntax_tree-rbs (1.0.0)

@kddnewton
Copy link
Member

Dup of ruby-syntax-tree/syntax_tree#122

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants