Skip to content

Commit

Permalink
Use first method instead of square brackets to support 2.5 and 2.6 ve…
Browse files Browse the repository at this point in the history
…rsions
  • Loading branch information
kaiquekandykoga committed Sep 20, 2021
1 parent 0504b93 commit ec23092
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/irb/ruby-lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/irb/test_ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit ec23092

Please sign in to comment.