Skip to content

Commit

Permalink
[ruby/irb] Pager should be disabled when TERM=dumb
Browse files Browse the repository at this point in the history
(ruby/irb#800)

For apps/libs that test against IRB, it's recommended to set `TERM=dumb`
so they get minimum disruption from Reline's interactive-focus features.

Therefore, we should follow the convention to disable pager when `TERM=dumb`.

ruby/irb@8a3002a39e
  • Loading branch information
st0012 authored and matzbot committed Dec 5, 2023
1 parent 94bf9f8 commit ef387e6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/irb/pager.rb
Expand Up @@ -18,7 +18,7 @@ def page_content(content, **options)
end

def page(retain_content: false)
if IRB.conf[:USE_PAGER] && STDIN.tty? && pager = setup_pager(retain_content: retain_content)
if should_page? && pager = setup_pager(retain_content: retain_content)
begin
pid = pager.pid
yield pager
Expand All @@ -40,6 +40,10 @@ def page(retain_content: false)

private

def should_page?
IRB.conf[:USE_PAGER] && STDIN.tty? && ENV["TERM"] != "dumb"
end

def content_exceeds_screen_height?(content)
screen_height, screen_width = begin
Reline.get_screen_size
Expand Down

0 comments on commit ef387e6

Please sign in to comment.