aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStan Lo <stan001212@gmail.com>2023-12-05 16:03:01 +0000
committergit <svn-admin@ruby-lang.org>2023-12-05 16:03:06 +0000
commitef387e67307504f41baf45a5b06a10eb82933788 (patch)
tree9f7fd2d3c07638846e017ac4c8fa786b64125ada
parent94bf9f80377d32e9dd5123bdf487b55b5e06a851 (diff)
downloadruby-ef387e67307504f41baf45a5b06a10eb82933788.tar.gz
[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
-rw-r--r--lib/irb/pager.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/irb/pager.rb b/lib/irb/pager.rb
index a0db5e93b4..d503487865 100644
--- a/lib/irb/pager.rb
+++ b/lib/irb/pager.rb
@@ -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