Skip to content

Commit

Permalink
fix formating percent_array_literal fails on ruby 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kzkn committed Dec 10, 2023
1 parent 30572a0 commit 36d62e3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/rufo/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2315,6 +2315,12 @@ def visit_q_or_i_array(node)
write_indent next_indent
end
next_token

# fix for 3.3 ripper change. two :on_words_sep are generated for "#\n "
while current_token_kind == :on_words_sep
next_token

Check warning on line 2321 in lib/rufo/formatter.rb

View check run for this annotation

Codecov / codecov/patch

lib/rufo/formatter.rb#L2321

Added line #L2321 was not covered by tests
end

has_space = true if current_token_value.start_with?(" ")
end

Expand All @@ -2337,7 +2343,7 @@ def visit_q_or_i_array(node)
next_token
write_line
write_indent(column)
# "\n "
# two :on_words_sep are generated for "#\n " on ruby 3.3
while current_token_kind == :on_words_sep
next_token

Check warning on line 2348 in lib/rufo/formatter.rb

View check run for this annotation

Codecov / codecov/patch

lib/rufo/formatter.rb#L2348

Added line #L2348 was not covered by tests
end
Expand Down

0 comments on commit 36d62e3

Please sign in to comment.