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

Fix debug command in nomultiline mode #1006

Merged
merged 2 commits into from
Sep 20, 2024
Merged

Conversation

tompng
Copy link
Member

@tompng tompng commented Sep 17, 2024

Fixes #909 and #1003

Fix this bug

% irb --readline
irb(main):001> binding.irb
irb(main):001> debug
/Users/tomoya.ishida/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/irb-1.14.0/lib/irb/debug.rb:72:in `block in setup': undefined method `call' for nil (NoMethodError)

            irb_output_modifier_proc.call(output, complete: complete)
                                    ^^^^^

rendering test conflicts with #1001

@st0012 st0012 added the bug Something isn't working label Sep 17, 2024
@@ -649,6 +649,21 @@ def parse_command(code)
end
end

def colorize_code(input, complete:)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel colorize_input express the intent better and is less likely to be confused with Color.colorize_code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks better, but I have one concern. colorize_input colorizes output. I think it is an input, but Reline's api calls it output.
Do you think the code below is acceptable? IMO... maybe yes?

Reline.output_modifier_proc = proc do |output, complete:|
  IRB.CurrentContext.colorize_input(output, complete: complete)
end

Copy link
Member

@st0012 st0012 Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In IRB's context, it is input indeed. And in Reline's context, I think calling it both input or output are technically correct? Though since there's no input_modifier_proc, I feel it'd be a better name for the library user's perspective.

In this case, I feel a comment to clarify it would be enough, and maybe rename the output variable to input?

lib/irb/debug.rb Outdated Show resolved Hide resolved
@st0012
Copy link
Member

st0012 commented Sep 19, 2024

Thank you!

@tompng tompng merged commit 71f4d6b into ruby:master Sep 20, 2024
30 checks passed
@tompng tompng deleted the debug_readline_bugfix branch September 20, 2024 10:13
matzbot pushed a commit to ruby/ruby that referenced this pull request Sep 20, 2024
(ruby/irb#1006)

* Fix debug command in nomultiline mode

* context.colorize_code -> context.colorize_input

ruby/irb@71f4d6bfb5
Juan5212

This comment was marked as spam.

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.

Debug command does not work when IRB.conf[:USE_SINGLELINE] is set
3 participants