ruby-changes:64375
From: aycabta <ko1@a...>
Date: Sun, 20 Dec 2020 16:34:16 +0900 (JST)
Subject: [ruby-changes:64375] 8b6aaeaddf (master): [ruby/irb] Handle rest of tokens correctly if no newline at last
https://git.ruby-lang.org/ruby.git/commit/?id=8b6aaeaddf From 8b6aaeaddf2d13833c0540490a84741035a3a808 Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Sun, 20 Dec 2020 12:20:00 +0900 Subject: [ruby/irb] Handle rest of tokens correctly if no newline at last https://github.com/ruby/irb/commit/f3c8edad2a diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index 8507717..040c93e 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -63,16 +63,23 @@ class RubyLex https://github.com/ruby/ruby/blob/trunk/lib/irb/ruby-lex.rb#L63 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/