@@ -243,35 +243,7 @@ def visit(node)
243243 when :string_concat
244244 visit_string_concat node
245245 when :@tstring_content
246- # [:@tstring_content, "hello ", [1, 1]]
247- heredoc , tilde = @current_heredoc
248- looking_at_newline = current_token_kind == :on_tstring_content && current_token_value == "\n "
249- if heredoc && tilde && !@last_was_newline && looking_at_newline
250- check :on_tstring_content
251- consume_token_value ( current_token_value )
252- next_token
253- else
254- # For heredocs with tilde we sometimes need to align the contents
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
267- end
268- else
269- while ( current_token_kind == :on_ignored_sp ) ||
270- ( current_token_kind == :on_tstring_content )
271- consume_token current_token_kind
272- end
273- end
274- end
246+ visit_at_tstring_content node
275247 when :string_content
276248 # [:string_content, exp]
277249 visit_exps node [ 1 ..-1 ] , with_lines : false
@@ -741,6 +713,38 @@ def visit_string_concat(node)
741713 visit string2
742714 end
743715
716+ def visit_at_tstring_content ( _node )
717+ # [:@tstring_content, "hello ", [1, 1]]
718+ heredoc , tilde = @current_heredoc
719+ looking_at_newline = current_token_kind == :on_tstring_content && current_token_value == "\n "
720+ if heredoc && tilde && !@last_was_newline && looking_at_newline
721+ check :on_tstring_content
722+ consume_token_value ( current_token_value )
723+ next_token
724+ else
725+ # For heredocs with tilde we sometimes need to align the contents
726+ if heredoc && tilde
727+ while ( current_token_kind == :on_ignored_sp ) ||
728+ ( current_token_kind == :on_tstring_content )
729+ if @last_was_newline && current_token_value != "\n "
730+ write_indent ( next_indent )
731+ @last_was_newline = false
732+ end
733+ if current_token_kind == :on_ignored_sp
734+ skip_ignored_space
735+ else
736+ consume_token current_token_kind
737+ end
738+ end
739+ else
740+ while ( current_token_kind == :on_ignored_sp ) ||
741+ ( current_token_kind == :on_tstring_content )
742+ consume_token current_token_kind
743+ end
744+ end
745+ end
746+ end
747+
744748 def visit_string_interpolation ( node )
745749 # [:string_embexpr, exps]
746750 consume_token :on_embexpr_beg
0 commit comments