Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/prism/translation/parser/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2144,7 +2144,9 @@ def string_nodes_from_line_continuations(unescaped, escaped, start_offset, openi
.each do |lines|
escaped_lengths << lines.sum(&:bytesize)
unescaped_lines_count = lines.sum do |line|
line.scan(/(\\*)n/).count { |(backslashes)| backslashes&.length&.odd? || false }
count = line.scan(/(\\*)n/).count { |(backslashes)| backslashes&.length&.odd? }
count -= 1 if !line.end_with?("\n") && count > 0
count
end
extra = 1
extra = lines.count if percent_array # Account for line continuations in percent arrays
Expand Down
4 changes: 4 additions & 0 deletions test/prism/fixtures/dstring.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@ b\nar
#{}
"

"foo
\n#{}bar\n\n#{}
a\nb\n#{}\nc\n"

"
’"
4 changes: 4 additions & 0 deletions test/prism/fixtures/strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ foo\
b\nar
"

"foo
\nbar\n\n
a\nb\n\nc\n"

%q{abc}

%s[abc]
Expand Down
58 changes: 51 additions & 7 deletions test/prism/snapshots/dstring.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading