summaryrefslogtreecommitdiff
path: root/lib/irb/color.rb
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2020-06-07 23:29:01 +0900
committeraycabta <aycabta@gmail.com>2020-07-22 02:31:46 +0900
commitc72a2fad9717a6090aa792c31eb0043886d0fb39 (patch)
treea4de42bfbdb0792d131f502a28292a57c17a1fdc /lib/irb/color.rb
parent1dfd24a7fc4e2877d49d2a3326925080e2972cf1 (diff)
[ruby/irb] Simplify RubyLex.compile_with_errors_suppressed
nobu-san reviewed, https://github.com/ruby/irb/pull/106#pullrequestreview-423400033 > How about lexer = Ripper::Lexer.new(";\n#{code}", nil, 0)? > Encoding pragma is effective only at the beginning. > And the semicolon and newline will be skipped because the position is before > the initial pos. I employ the way. Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> https://github.com/ruby/irb/commit/e593cc65b7
Diffstat (limited to 'lib/irb/color.rb')
-rw-r--r--lib/irb/color.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/irb/color.rb b/lib/irb/color.rb
index d325c8dede..9ee1348671 100644
--- a/lib/irb/color.rb
+++ b/lib/irb/color.rb
@@ -155,8 +155,8 @@ module IRB # :nodoc:
pos = [1, 0]
verbose, $VERBOSE = $VERBOSE, nil
- RubyLex.compile_with_errors_suppressed(code) do |inner_code|
- lexer = Ripper::Lexer.new(inner_code)
+ RubyLex.compile_with_errors_suppressed(code) do |inner_code, line_no|
+ lexer = Ripper::Lexer.new(inner_code, '(ripper)', line_no)
if lexer.respond_to?(:scan) # Ruby 2.7+
lexer.scan.each do |elem|
str = elem.tok