[ruby/irb] Pager should be disabled when TERM=dumb

(https://github.com/ruby/irb/pull/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`.

https://github.com/ruby/irb/commit/8a3002a39e
This commit is contained in:
Stan Lo 2023-12-05 16:03:01 +00:00 committed by git
parent 94bf9f8037
commit ef387e6730

View File

@ -18,7 +18,7 @@ module IRB
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
@ -40,6 +40,10 @@ module IRB
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