Skip to content

Add a pager to evaluation result #495

Closed

Description

@nickjer

Description

Currently when IRB outputs something with a large amount of data such as MyRecord.all in Rails it will pause for a long time and then dump everything to the screen at once. This can be a bit of a pain when coming from Pry where it comes with a pager that will instantly return and allow the user to navigate around in the data.

You can reproduce this wait with...

> [1] * 1_000_000

I was wondering if IRB could add a pager similar to Pry. If so, I'd be happy to explore it but also don't want to step on any toes if this is a no go.

Activity

  1. st0012 commented on May 23, 2023

    @st0012
    Member

    I gave it a try but unfortunately simply paging the result won’t solve the issue. The slowness comes from IRB using ColorPrinter.pp to generate the inspected value string all at once. And value inspection behavior is customisable in IRB so it’s not something we can easily change.

    That being said, paging the generated long string itself doesn’t seem difficult to achieve. Do you think if we implement only that part for now will already help? Or the main concern is just the rendering speed?

  2. nickjer commented on May 23, 2023

    @nickjer
    Author

    That is unfortunate. The rendering speed is definitely the main issue, but there is still significant value in the pager.

    For instance, I regularly use the pager in Pry to find text (this feature especially) or scroll back-and-forth using the vim keybindings. Basically it makes navigating large chunks of output so much easier. That being said, if it makes its way into IRB that would be amazing.

    And value inspection behavior is customisable in IRB so it’s not something we can easily change.

    So when you say it is customizable, does that mean it can be disabled through configuration (e.g., like an environment variable)?

  3. changed the title [-]Add a pager due to long waits[/-] [+]Add a pager to evaluation result[/+] on Nov 8, 2023
  4. st0012 commented on Nov 8, 2023

    @st0012
    Member

    Sorry for the long delay.

    So when you say it is customizable, does that mean it can be disabled through configuration (e.g., like an environment variable)?

    Yes, you can configure it with IRB.conf[:INSPECT_MODE] in your .irbrc. Here's a list of default inspectors in IRB. But you can also define your own with the same APIs.

    I think to dramatically improve the speed in your example input, setting it to IRB.conf[:INSPECT_MODE] = :to_s # or :raw or false should do the trick.

  5. osyoyu commented on Nov 13, 2023

    @osyoyu

    What do you think about adding a timeout to the coloring process? I've sent a patch for that in #759 .

    Nonetheless, pager support would be a super great feature for me, regardless of coloring! Sometimes I have to scroll back 1000+ lines when I inspect large ActiveRecord query results; pagers would help a lot there.

  6. st0012 commented on Dec 17, 2023

    @st0012
    Member

    I'm closing this now as pager support for evaluation result has been implemented in #784 and there's no good way to get around slow value inspection at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions