Bug #17557
closedIRB array returned in multiple lines
Description
Hi Rubysts. In previous versions of IRB an array was displayed in a single line like:
's'.methods
=> [:unicode_normalize, :unicode_normalize!, :ascii_only?, :to_r, :unpack, ..., :!=, :equal?, :__id__, :instance_eval, :instance_exec]
But in version 1.3.1 (2021-01-12) the array is returned in multiple lines:
's'.methods
=>
[:unicode_normalize,
:unicode_normalize!,
:ascii_only?,
:to_r,
:unpack,
...,
:!=,
:equal?,
:__id__,
:instance_eval,
:instance_exec]
Is there a way to toggle this behavior, perhaps IRB.conf?
Updated by k0kubun (Takashi Kokubun) almost 4 years ago
- Status changed from Open to Closed
We changed the default IRB inspector from inspect-based one to pretty_inspect-based one, which prints a content in multiple lines when it exceeds 79 chars, for Ruby 3.1+ IRB.
Given that, we have two choices:
- Use
IRB.conf[:INSPECT_MODE] = :inspect
in your ~/.irbrc. This makes the behavior compatible with Ruby 3.0 IRB, which, however, cannot syntax-highlight an inspect output of objects like Struct. - Dynamically change the threshold 79 using Reline's API in the new pp-based inspector. It would still print an array in a single line as long as it's not too large.
2 would be a valid feature request, but because my comment already addresses the ticket's concern, I'm closing this ticket.
Updated by k0kubun (Takashi Kokubun) almost 4 years ago
The point 2 was merged to IRB master https://github.com/ruby/irb/pull/174. It seems 's'.methods
returns way more things than what's written in the description and thus it doesn't help your case though.
Updated by sergioro (Sergio Romero) almost 4 years ago
Thanks, (1) solved the issue.