From 8a3002a39e9702d83b2379351ee57e99cb22eec5 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Tue, 5 Dec 2023 16:03:01 +0000 Subject: [PATCH] Pager should be disabled when TERM=dumb (#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`. --- lib/irb/pager.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/irb/pager.rb b/lib/irb/pager.rb index a0db5e93b..d50348786 100644 --- a/lib/irb/pager.rb +++ b/lib/irb/pager.rb @@ -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 @@ -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