From ce0a352e34022b46397b5a2712f03bafc1b505ad Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Fri, 7 Jun 2024 14:38:54 -0400 Subject: [PATCH] [ruby/prism] Use correct newlines for heredoc inner lines https://github.com/ruby/prism/commit/4a9a7a62af Co-authored-by: Jason Kim Co-authored-by: Adam Hess --- lib/prism/translation/parser/compiler.rb | 32 +++++++++++++++--------- test/prism/ruby/parser_test.rb | 6 ++--- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/lib/prism/translation/parser/compiler.rb b/lib/prism/translation/parser/compiler.rb index c6205e542d..7e4b1d984a 100644 --- a/lib/prism/translation/parser/compiler.rb +++ b/lib/prism/translation/parser/compiler.rb @@ -2057,23 +2057,31 @@ module Prism node.parts.each do |part| pushing = if part.is_a?(StringNode) && part.unescaped.include?("\n") - unescaped = part.unescaped.lines(chomp: true) - escaped = part.content.lines(chomp: true) + unescaped = part.unescaped.lines + escaped = part.content.lines - escaped_lengths = - if node.opening.end_with?("'") - escaped.map { |line| line.bytesize + 1 } - else - escaped.chunk_while { |before, after| before.match?(/(?