From ec23092a2246806b037d25433cb159d0154599e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ka=C3=ADque=20Kandy=20Koga?= Date: Mon, 20 Sep 2021 07:37:37 -0300 Subject: [PATCH] Use first method instead of square brackets to support 2.5 and 2.6 versions --- lib/irb/ruby-lex.rb | 2 +- test/irb/test_ruby_lex.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index ebc9e36f3..0c92d83d6 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -825,7 +825,7 @@ def check_termination_in_prev_line(code, context: nil) private def heredoc_scope?(line_index) - tokens = @tokens[..line_index].select { |t| [:on_heredoc_beg, :on_heredoc_end].include?(t.event) } + tokens = @tokens.first(line_index).select { |t| [:on_heredoc_beg, :on_heredoc_end].include?(t.event) } tokens[-1]&.event == :on_heredoc_beg end end diff --git a/test/irb/test_ruby_lex.rb b/test/irb/test_ruby_lex.rb index 188652e6e..99f6431cf 100644 --- a/test/irb/test_ruby_lex.rb +++ b/test/irb/test_ruby_lex.rb @@ -465,10 +465,10 @@ def test_do_corresponding_to_loop def test_heredoc_with_indent input_with_correct_indents = [ - Row.new(%q(<<~Q), 0, 0, 0), + Row.new(%q(<<~Q), nil, 0, 0), Row.new(%q({), 0, 0, 0), Row.new(%q( #), 2, 0, 0), - Row.new(%q(}), 0, 0, 0), + Row.new(%q(}), 0, 0, 0) ] lines = []