Skip to content

Commit

Permalink
Revert "Optimize show_source command further"
Browse files Browse the repository at this point in the history
This reverts commit 27dd286.

This is to fix the test I added.

(I separated commits to test a new behavior of ruby-commit-hook)
  • Loading branch information
k0kubun committed Oct 11, 2021
1 parent 68e6ca9 commit fe055d5
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/irb/cmd/show_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,12 @@ def find_end(file, first_line)
lex = RubyLex.new
lines = File.read(file).lines[(first_line - 1)..-1]
tokens = RubyLex.ripper_lex_without_warning(lines.join)

code = +""
prev_tokens = []

# chunk with line number
tokens.chunk { |tok| tok[0][0] }.each do |lnum, chunk|
code << lines[lnum]
code = lines[0..lnum].join
prev_tokens.concat chunk

continue = lex.process_continue(prev_tokens)
code_block_open = lex.check_code_block(code, prev_tokens)
if !continue && !code_block_open
Expand Down

0 comments on commit fe055d5

Please sign in to comment.