Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeated newlines in multi-line strings are ignored #372

Open
sjahu opened this issue Jan 28, 2022 · 0 comments
Open

Repeated newlines in multi-line strings are ignored #372

sjahu opened this issue Jan 28, 2022 · 0 comments

Comments

@sjahu
Copy link

sjahu commented Jan 28, 2022

(Moved from pry/pry#2227 because it seems like this is a behaviour introduced by pry-byebug, not one that exists in pry on its own.)

When multiline strings are entered in the interpreter, repeated newlines are ignored and compacted to a single newline. This behaviour is inconsistent with how multi-line strings are handled by the ruby parser and by irb (see example below).

Pry results, missing newlines:

[14] pry(main)> <<ASDF
[14] pry(main)* 1
[14] pry(main)* 
[14] pry(main)* 
[14] pry(main)* 
[14] pry(main)* 
[14] pry(main)* 2
[14] pry(main)* 
[14] pry(main)* 
[14] pry(main)* 
[14] pry(main)* 
[14] pry(main)* 4
[14] pry(main)* 
[14] pry(main)* 
[14] pry(main)* 
[14] pry(main)* 
[14] pry(main)* 5
[14] pry(main)* ASDF
=> "1\n2\n4\n5\n"
[15] pry(main)> %q(
[15] pry(main)* 1
[15] pry(main)* 
[15] pry(main)* 
[15] pry(main)* 
[15] pry(main)* 
[15] pry(main)* 2
[15] pry(main)* 
[15] pry(main)* 
[15] pry(main)* 
[15] pry(main)* 
[15] pry(main)* 4
[15] pry(main)* )
=> "\n1\n2\n4\n"
[16] pry(main)> "
[16] pry(main)* 
[16] pry(main)* 
[16] pry(main)* 
[16] pry(main)* 
[16] pry(main)* 3
[16] pry(main)* 
[16] pry(main)* 
[16] pry(main)* 
[16] pry(main)* 
[16] pry(main)* 5
[16] pry(main)* 
[16] pry(main)* 
[16] pry(main)* 
[16] pry(main)* 
[16] pry(main)* 3"
=> "\n3\n5\n3"
[17] pry(main)>

irb results, as expected:

irb(main):029:0> "
irb(main):030:0" 
irb(main):031:0" 
irb(main):032:0" 
irb(main):033:0" d
irb(main):034:0" 
irb(main):035:0" 
irb(main):036:0" 
irb(main):037:0" a
irb(main):038:0" 
irb(main):039:0" 
irb(main):040:0" 
irb(main):041:0" 
irb(main):042:0" s
irb(main):043:0" 
irb(main):044:0" 
irb(main):045:0" 
irb(main):046:0" f"
=> "\n\n\n\nd\n\n\n\na\n\n\n\n\ns\n\n\n\nf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant