fables-tales / rubyfmt

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

`rescue; else` blocks nested in outer `else` blocks misplaces comments #460

Open reese opened 8 months ago

reese commented 8 months ago

Input file

if stuff
else
  # This message should stay here!
  begin
  else
  end
end

Rubyfmt's output

if stuff

  # This message should stay here!

else
  begin
  else
  end
end

This breaks because

I'd expect the comment to remain unchanged, but I think the line winding for else blocks in begin/rescue may be busted.