Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page the output in irb:rdbg sessions too #1043

Merged
merged 1 commit into from
Dec 11, 2024
Merged

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Dec 10, 2024

IRB started to page its evaluation output and it became a useful feature for users. However, in irb:rdbg sessions, the output is not paged so the sudden change in behavior is surprising and inconvenient.

This commit makes irb:rdbg sessions page the output of the debugger too.

Notes:

  • I didn't add a test for it as we currently don't have a way to test pager output.
  • When printing results from ThreadClient, Debug::UI#puts will always receive string. So we only need to activate pager in that case. In fact, debug most of the time passes string to this method, except for when printing exception backtrace.

IRB started to page its evaluation output and it became a useful feature
for users. However, in `irb:rdbg` sessions, the output is not paged so
the sudden change in behavior is surprising and inconvenient.

This commit makes `irb:rdbg` sessions page the output of the debugger
too.
@st0012 st0012 added the enhancement New feature or request label Dec 10, 2024
@tompng
Copy link
Member

tompng commented Dec 11, 2024

This input will launch the pager 3 times.

irb:rdbg(main):025> outline Object.new.tap{|o|['a','b','c'].each{o.define_singleton_method(_1*10000){}}}

This part calls Debug::UI#puts several times to print a single output.
https://github.com/ruby/debug/blob/9c4279598e9e0376657b3813bf76a206f1f97beb/lib/debug/session.rb#L278C7-L278C13

# in DEBUGGER__::Session#process_event
output.each{|str| @ui.puts str} if ev != :suspend

I think this is just an acceptable edge case. Maybe we can fix it in debug.
What do you think?

@st0012
Copy link
Member Author

st0012 commented Dec 11, 2024

Thanks for catching that. Since outline is just a ported version of ls (ruby/debug#173), an alternative could be that we somehow alias outline to IRB's ls command in irb:rdbg mode 🤔

@st0012
Copy link
Member Author

st0012 commented Dec 11, 2024

an alternative could be that we somehow alias outline to IRB's ls command in irb:rdbg mode

Actually not cause we need to have an outline command class for that to work. And I don't think it's worth introducing a new command (even just as an alias) just to work around this edge case. I'll submit a PR to debug if people does hit this case.

@st0012 st0012 merged commit 8241ec9 into master Dec 11, 2024
59 checks passed
@st0012 st0012 deleted the page-irb-rdbg-output branch December 11, 2024 11:30
matzbot pushed a commit to ruby/ruby that referenced this pull request Dec 11, 2024
(ruby/irb#1043)

IRB started to page its evaluation output and it became a useful feature
for users. However, in `irb:rdbg` sessions, the output is not paged so
the sudden change in behavior is surprising and inconvenient.

This commit makes `irb:rdbg` sessions page the output of the debugger
too.

ruby/irb@8241ec9a0c
@technicalpickles
Copy link

Thanks for fixing this! I asked about this on the ruby-dx slack and was not effecting a solution this fast for it 😁

@st0012 st0012 added bug Something isn't working and removed enhancement New feature or request labels Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

3 participants