-
Notifications
You must be signed in to change notification settings - Fork 120
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
Indent multiline percent literals #643
Conversation
While testing this in IRB, I found a weird behaviour and a crash, which are both recorded in this video: Screen.Recording.2023-07-14.at.18.41.49.movI tried to type the input listed in But after typing
On master it doesn't crash, just adds another blank line: |
The weird behavior is mostly https://bugs.ruby-lang.org/issues/19563 and maybe partially https://bugs.ruby-lang.org/issues/19736 code = ["<<A+%W[\#{<<B", "\#{<<C+%W[", "a", "C", "", ""].join("\n")
puts '===original==='
puts code
puts '===ripper==='
puts Ripper.tokenize(code).join
puts '===RubyLex===' # interpolates DATA part and missing token ignored by ripper
puts RubyLex.ripper_lex_without_warning(code).map(&:tok).join
This is causing line number mismatch of input text, colored text and prompt list. |
Thanks for the explanation. I can confirm that crash and the weird issue don't happen with Ruby head. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This pull request implements percent literal indenting, which I pend implementing in #500 to not change the behavior at that time.
Indented percent literal is used in IRB and also in ruby/ruby.
You can search with this regexp:
%[a-z]?[({\[]\n