Skip to content

Fix redisplay/insert_text called from pre_input_hook - #742

Merged
tompng merged 2 commits into
ruby:masterfrom
tompng:fix_pre_input_hook_bug
Sep 3, 2024
Merged

tompng merged 2 commits into
ruby:masterfrom
tompng:fix_pre_input_hook_bug

Conversation

@tompng

@tompng tompng commented Sep 3, 2024

Copy link
Copy Markdown
Member

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

Comment thread 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
Copy Markdown
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)

@tompng tompng Sep 3, 2024 •

Copy link
Copy Markdown
Member Author

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

@ima1zumi ima1zumi left a comment

Copy link
Copy Markdown
Member

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
@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
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants