Format tool removes whitespace from heredoc #4400
Labels
help wanted
This issue is generally accepted and needs someone to pick it up
kind:bug
topic:tools:formatter
Milestone
The format tool shows an odd and unwanted behaviour with heredocs: In some cases, when the heredoc uses leading whitespace, the formatter removes a single whitespace at the beginning. Multiple runs of the formatter each remove only one whitespace until there is none left. It removes only leading whitespace which is to be ignored, so the meaning of the source code does not change. Nevertheless, the leading whitespace is usually there for a reason (readability) and it is annoying to revert.
Example:
Result of
crystal tool format
:Result of running
crystal tool format
four times:I found this to happen only when the heredoc is a value in a hash definition, but there might be other cases, too. The heredoc without the hash will not be altered:
The text was updated successfully, but these errors were encountered: