Skip to content

Commit

Permalink
Add workaround for lines==[nil] passed to auto_indent when exit IRB w…
Browse files Browse the repository at this point in the history
…ith CTRL+d
  • Loading branch information
tompng committed Jun 19, 2023
1 parent 94b810b commit 1e493c9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/irb/ruby-lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def configure_io(io)

if @io.respond_to?(:auto_indent) and @context.auto_indent_mode
@io.auto_indent do |lines, line_index, byte_pointer, is_newline|
next nil if lines == [nil] # Workaround for exit IRB with CTRL+d
next nil if !is_newline && lines[line_index]&.byteslice(0, byte_pointer)&.match?(/\A\s*\z/)

code = lines[0..line_index].map { |l| "#{l}\n" }.join
Expand Down

0 comments on commit 1e493c9

Please sign in to comment.