mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/irb] Rewrite on_scan proc to be more readable.
https://github.com/ruby/irb/commit/da54e7f081
This commit is contained in:
parent
78cb638002
commit
369f1668cd
1 changed files with 10 additions and 6 deletions
|
@ -176,14 +176,18 @@ module IRB # :nodoc:
|
|||
end
|
||||
|
||||
on_scan = proc do |elem|
|
||||
str = elem.tok
|
||||
start_pos = line_positions[elem.pos[0] - 1] + elem.pos[1]
|
||||
end_pos = start_pos + str.bytesize
|
||||
next if start_pos < byte_pos
|
||||
|
||||
yield(nil, inner_code.byteslice(byte_pos...start_pos), nil) if byte_pos < start_pos
|
||||
yield(elem.event, str, elem.state)
|
||||
byte_pos = end_pos
|
||||
# yield uncolorable code
|
||||
if byte_pos < start_pos
|
||||
yield(nil, inner_code.byteslice(byte_pos...start_pos), nil)
|
||||
end
|
||||
|
||||
if byte_pos <= start_pos
|
||||
str = elem.tok
|
||||
yield(elem.event, str, elem.state)
|
||||
byte_pos = start_pos + str.bytesize
|
||||
end
|
||||
end
|
||||
|
||||
if lexer.respond_to?(:scan) # Ruby 2.7+
|
||||
|
|
Loading…
Reference in a new issue