mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/irb] Revert "Optimize show_source command further"
This reverts commit 27dd2867cda5c789efaa5078214ad2fd82adcebf. This is to fix the test I added. (I separated commits to test a new behavior of ruby-commit-hook) https://github.com/ruby/irb/commit/fe055d521a
This commit is contained in:
parent
3112e876a1
commit
cf74755921
1 changed files with 1 additions and 4 deletions
|
@ -61,15 +61,12 @@ module IRB
|
||||||
lex = RubyLex.new
|
lex = RubyLex.new
|
||||||
lines = File.read(file).lines[(first_line - 1)..-1]
|
lines = File.read(file).lines[(first_line - 1)..-1]
|
||||||
tokens = RubyLex.ripper_lex_without_warning(lines.join)
|
tokens = RubyLex.ripper_lex_without_warning(lines.join)
|
||||||
|
|
||||||
code = +""
|
|
||||||
prev_tokens = []
|
prev_tokens = []
|
||||||
|
|
||||||
# chunk with line number
|
# chunk with line number
|
||||||
tokens.chunk { |tok| tok[0][0] }.each do |lnum, chunk|
|
tokens.chunk { |tok| tok[0][0] }.each do |lnum, chunk|
|
||||||
code << lines[lnum]
|
code = lines[0..lnum].join
|
||||||
prev_tokens.concat chunk
|
prev_tokens.concat chunk
|
||||||
|
|
||||||
continue = lex.process_continue(prev_tokens)
|
continue = lex.process_continue(prev_tokens)
|
||||||
code_block_open = lex.check_code_block(code, prev_tokens)
|
code_block_open = lex.check_code_block(code, prev_tokens)
|
||||||
if !continue && !code_block_open
|
if !continue && !code_block_open
|
||||||
|
|
Loading…
Add table
Reference in a new issue