File tree Expand file tree Collapse file tree 2 files changed +26
-13
lines changed
spec/lib/rufo/formatter_source_specs Expand file tree Collapse file tree 2 files changed +26
-13
lines changed Original file line number Diff line number Diff line change @@ -252,22 +252,22 @@ def visit(node)
252252 next_token
253253 else
254254 # For heredocs with tilde we sometimes need to align the contents
255- if heredoc && tilde && @last_was_newline
256- unless ( current_token_value == "\n " ||
257- current_token_kind == :on_heredoc_end )
258- write_indent ( next_indent )
259- end
260- skip_ignored_space
261- if current_token_kind == :on_tstring_content
262- check :on_tstring_content
263- consume_token_value ( current_token_value )
264- next_token
255+ if heredoc && tilde
256+ while ( current_token_kind == :on_ignored_sp ) ||
257+ ( current_token_kind == :on_tstring_content )
258+ if @last_was_newline && current_token_value != "\n "
259+ write_indent ( next_indent )
260+ @last_was_newline = false
261+ end
262+ if current_token_kind == :on_ignored_sp
263+ skip_ignored_space
264+ else
265+ consume_token current_token_kind
266+ end
265267 end
266268 else
267269 while ( current_token_kind == :on_ignored_sp ) ||
268- ( current_token_kind == :on_tstring_content ) ||
269- ( current_token_kind == :on_embexpr_beg )
270- check current_token_kind
270+ ( current_token_kind == :on_tstring_content )
271271 break if current_token_kind == :on_embexpr_beg
272272 consume_token current_token_kind
273273 end
Original file line number Diff line number Diff line change 273273 heredoc
274274 EOF
275275}
276+
277+ #~# ORIGINAL issue_342
278+
279+ foox <<~TEXT
280+ #{ x } x
281+ a
282+ TEXT
283+
284+ #~# EXPECTED
285+ foox <<~TEXT
286+ #{ x } x
287+ a
288+ TEXT
You can’t perform that action at this time.
0 commit comments