Skip to content

Commit

Permalink
Parser: apply string pieces combination even if heredoc has no indent (
Browse files Browse the repository at this point in the history
…#9475)

Fixed #9473

It is important to simplify the formatter implementation.
  • Loading branch information
makenowjust authored Sep 5, 2020
1 parent e6498c4 commit 52c750e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions spec/compiler/formatter/formatter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,8 @@ describe Crystal::Formatter do
assert_format "<<-FOO\n#{"foo"}bar\nFOO"
assert_format "<<-FOO\nbar#{"foo"}\nFOO"
assert_format "<<-FOO\nbar#{"foo"}bar\nFOO"
assert_format "<<-FOO\nfoo\n#{"foo"}\nFOO"
assert_format "<<-FOO\nfoo\n#{1}\nFOO"

assert_format "#!shebang\n1 + 2"

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/syntax/parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2145,7 +2145,7 @@ module Crystal
end

def needs_heredoc_indent_removed?(delimiter_state)
delimiter_state.kind == :heredoc && delimiter_state.heredoc_indent > 0
delimiter_state.kind == :heredoc && delimiter_state.heredoc_indent >= 0
end

def remove_heredoc_indent(pieces : Array, indent)
Expand Down

0 comments on commit 52c750e

Please sign in to comment.