fables-tales / rubyfmt

Ruby Autoformatter!
MIT License
1.07k stars 50 forks source link

Unexpected formatting of block using curly-brace notation #461

Open damolina-stripe opened 7 months ago

damolina-stripe commented 7 months ago

Input file

    def foo(e)
      e.to_s.each_line(chomp: true) { 
        |l| X }
    end

In my repro, X was a long namespaced-method call so I was looking to learn whether rubyfmt would recommend to keep as a single line or else.

Rubyfmt's output

    def foo(e)
      e.to_s.each_line(chomp: true) { |
          l
        | X }
    end

This breaks because

Unexpected formatting, breaking variable declaration across multiple lines seems wrong

  1. Not to break the declaration of |l|
  2. Probably, leave as is, make a single line, or ?
    def foo(e)
      e.to_s.each_line(chomp: true) {  |l| X }
    end