diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index b60dfcb97..e667a8a64 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -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