diff --git a/lib/irb/cmd/show_source.rb b/lib/irb/cmd/show_source.rb index dcba1d1c71..feff8315f6 100644 --- a/lib/irb/cmd/show_source.rb +++ b/lib/irb/cmd/show_source.rb @@ -61,12 +61,15 @@ module IRB 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[0..lnum].join + code << lines[lnum] 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