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 redisplay/insert_text called from pre_input_hook #742

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

tompng
Copy link
Member

@tompng tompng commented Sep 3, 2024

Fix https://bugs.ruby-lang.org/issues/20711
Add test for frequently used pre_input_hook pattern.

lib/reline.rb Outdated
def self.insert_text(*args, &block)
line_editor.insert_text(*args, &block)
def self.insert_text(text)
line_editor.insert_pasted_text(text)
Copy link
Member

Choose a reason for hiding this comment

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

Should we address the difference in naming in the future?

Also, could stop taking a block be a breaking change to some users? (I didn't find such usage with either Reline.insert_text or Readline.insert_text during a quick search on GH tho)

Copy link
Member Author

@tompng tompng Sep 3, 2024

Choose a reason for hiding this comment

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

It won't be a breaking change. line_editor.insert_text(text) only accepts one String argument.
Passing a block to a method that does not use a block does not raise any error.

naming

Nice catch, I renamed it to insert_multiline_text

It is now used from Reline.insert_text which is not inserting pasted text
Copy link
Member

@ima1zumi ima1zumi left a comment

Choose a reason for hiding this comment

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

LGTM

@tompng tompng merged commit 694a540 into ruby:master Sep 3, 2024
40 checks passed
@tompng tompng deleted the fix_pre_input_hook_bug branch September 3, 2024 15:19
matzbot pushed a commit to ruby/ruby that referenced this pull request Sep 3, 2024
(ruby/reline#742)

* Fix redisplay/insert_text called from pre_input_hook

* Rename insert_pasted_text to insert_multiline_text

It is now used from Reline.insert_text which is not inserting pasted text

ruby/reline@694a540939
yogo1212 pushed a commit to yogo1212/ruby that referenced this pull request Sep 4, 2024
(ruby/reline#742)

* Fix redisplay/insert_text called from pre_input_hook

* Rename insert_pasted_text to insert_multiline_text

It is now used from Reline.insert_text which is not inserting pasted text

ruby/reline@694a540939
@ima1zumi ima1zumi added the bug Something isn't working label Sep 5, 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