Skip to content

Commit 90471aa

Browse files
committed
refactor: simplify control flow
1 parent 15f160d commit 90471aa

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

lib/rufo/formatter.rb

+8-20
Original file line numberDiff line numberDiff line change
@@ -253,28 +253,16 @@ def visit(node)
253253
else
254254
# For heredocs with tilde we sometimes need to align the contents
255255
if heredoc && tilde
256-
if @last_was_newline
257-
unless (current_token_value == "\n" ||
258-
current_token_kind == :on_heredoc_end)
256+
while (current_token_kind == :on_ignored_sp) ||
257+
(current_token_kind == :on_tstring_content)
258+
if @last_was_newline && current_token_value != "\n"
259259
write_indent(next_indent)
260+
@last_was_newline = false
260261
end
261-
skip_ignored_space
262-
if current_token_kind == :on_tstring_content
263-
consume_token_value(current_token_value)
264-
next_token
265-
end
266-
else
267-
while (current_token_kind == :on_ignored_sp) ||
268-
(current_token_kind == :on_tstring_content)
269-
if @last_was_newline
270-
write_indent(next_indent)
271-
@last_was_newline = false
272-
end
273-
if current_token_kind == :on_ignored_sp
274-
skip_ignored_space
275-
else
276-
consume_token current_token_kind
277-
end
262+
if current_token_kind == :on_ignored_sp
263+
skip_ignored_space
264+
else
265+
consume_token current_token_kind
278266
end
279267
end
280268
else

0 commit comments

Comments
 (0)