Skip to content

Commit

Permalink
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 2 additions & 0 deletions spec/compiler/formatter/formatter_spec.cr
Original file line number Diff line number Diff line change
@@ -336,6 +336,8 @@ describe Crystal::Formatter do

assert_format "%w(one two three)", "%w(one two three)"
assert_format "%i(one two three)", "%i(one two three)"
assert_format "%w{one( two( three)}", "%w{one( two( three)}"
assert_format "%i{one( two( three)}", "%i{one( two( three)}"

assert_format "/foo/"
assert_format "/foo/imx"
3 changes: 3 additions & 0 deletions src/compiler/crystal/syntax/lexer.cr
Original file line number Diff line number Diff line change
@@ -296,6 +296,7 @@ module Crystal
when '(', '{', '[', '<'
start_char = next_char
next_char :SYMBOL_ARRAY_START
@token.raw = "%i#{start_char}" if @wants_raw
@token.delimiter_state = Token::DelimiterState.new(:symbol_array, start_char, closing_char(start_char))
else
@token.type = :"%"
@@ -335,6 +336,7 @@ module Crystal
when '(', '{', '[', '<'
start_char = next_char
next_char :STRING_ARRAY_START
@token.raw = "%w#{start_char}" if @wants_raw
@token.delimiter_state = Token::DelimiterState.new(:string_array, start_char, closing_char(start_char))
else
@token.type = :"%"
@@ -2399,6 +2401,7 @@ module Crystal
end

if current_char == @token.delimiter_state.end
@token.raw = current_char.to_s if @wants_raw
next_char
@token.type = :STRING_ARRAY_END
return @token
8 changes: 2 additions & 6 deletions src/compiler/crystal/tools/formatter.cr
Original file line number Diff line number Diff line change
@@ -633,11 +633,7 @@ module Crystal
next_token
when :STRING_ARRAY_START, :SYMBOL_ARRAY_START
first = true
if @token.type == :STRING_ARRAY_START
write "%w("
else
write "%i("
end
write @token.raw
count = 0
while true
has_space_newline = space_newline?
@@ -656,7 +652,7 @@ module Crystal
write @token.raw
first = false
when :STRING_ARRAY_END
write ")"
write @token.raw
next_token
break
end

0 comments on commit a8fbfb0

Please sign in to comment.