Handle properly stringifying single line blocks#15568
Merged
straight-shoota merged 4 commits intocrystal-lang:masterfrom Apr 18, 2025
Merged
Handle properly stringifying single line blocks#15568straight-shoota merged 4 commits intocrystal-lang:masterfrom
straight-shoota merged 4 commits intocrystal-lang:masterfrom
Conversation
61b983e to
d7c1550
Compare
straight-shoota
approved these changes
Mar 28, 2025
straight-shoota
pushed a commit
that referenced
this pull request
Apr 25, 2025
Follow up to #15568 to handle the case of significant whitespace before a block's body. Previously code like: ```cr {% ({"a" => "b"} of Nil => Nil).each do |k, v| # stuff and things k + v # foo bar k + v end %} ``` Would always be stringified as: ```cr {% ({"a" => "b"} of Nil => Nil).each do |k, v| k + v k + v end %} ``` But now results in: ```cr {% ({"a" => "b"} of Nil => Nil).each do |k, v| k + v k + v end %} ```
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on, and is similar to, #15305 but for
Blocknodes.Previously code like:
{% [1, 2, 3].each { |v| pp v } [1, 2, 3].each do |v| pp v end %}Would always stringify single-line blocks as a
do/endblock:{% [1, 2, 3].each do |v| pp(v) end [1, 2, 3].each do |v| pp(v) end %}But now, in-conjunction with the other PR, results in:
{% [1, 2, 3].each { |v| pp(v) } [1, 2, 3].each do |v| pp(v) end %}I threw a bunch of test cases at it with the assumption the code may not have had the formatter ran on it and all seems 👍.
Marking as draft and skipping CI. Will rebase/trigger CI once the other dependent PR is merged. But wanted to get this opened for feedback.