mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/irb] Handle rest of tokens correctly if no newline at last
https://github.com/ruby/irb/commit/f3c8edad2a
This commit is contained in:
parent
67ee1cbdd5
commit
8b6aaeaddf
1 changed files with 7 additions and 0 deletions
|
@ -63,16 +63,23 @@ class RubyLex
|
|||
tokens = ripper_lex_without_warning(lines.map{ |l| l + "\n" }.join)
|
||||
code = String.new
|
||||
partial_tokens = []
|
||||
unprocessed_tokens = []
|
||||
line_num_offset = 0
|
||||
tokens.each do |t|
|
||||
code << t[2]
|
||||
partial_tokens << t
|
||||
unprocessed_tokens << t
|
||||
if t[2].include?("\n")
|
||||
ltype, indent, continue, code_block_open = check_state(code, partial_tokens)
|
||||
result << @prompt.call(ltype, indent, continue || code_block_open, @line_no + line_num_offset)
|
||||
line_num_offset += 1
|
||||
unprocessed_tokens = []
|
||||
end
|
||||
end
|
||||
unless unprocessed_tokens.empty?
|
||||
ltype, indent, continue, code_block_open = check_state(code, unprocessed_tokens)
|
||||
result << @prompt.call(ltype, indent, continue || code_block_open, @line_no + line_num_offset)
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue