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

Input with eof and no newline bugfix #671

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

tompng
Copy link
Member

@tompng tompng commented Apr 3, 2024

Fix the bug below

# with readline-ext
$ printf "hello" | ruby -rreadline -e "p Readline.readline('>')"
>hello
"hello"

# with Reline master
$ printf "hello" | ruby -Ilib -rreline -e "p Reline.readline('>')"
>
""

The string "hello" is stored in @continuous_insertion_buffer, need to force input before finishing read.

In some environment (in my M2 Mac), pread raises IOError, so rescue Errno::ESPIPE, IOError change in ansi.rb is needed to test it.

omit if Reline.core.io_gate.win?
cmd = %Q{ruby -e 'print(%Q{abc def \\e\\r})' | ruby -I#{@pwd}/lib -rreline -e 'p Reline.readline(%{> })'}
start_terminal(40, 50, ['bash', '-c', cmd])
sleep 1
close
close rescue nil
Copy link
Member Author

@tompng tompng Apr 3, 2024

Choose a reason for hiding this comment

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

This test was always failing in my local environment.
If sleep on the previous line is too long, close will raise EOFError: end of file reached. If sleep time is too short, assert_screen will fail.
(In my environment, even sleep 0 is too long because start_terminal and close has sleep 0.1 internally. There is no best value. Need to fix yamatanooroti.)

@ima1zumi ima1zumi added the bug Something isn't working label Apr 5, 2024
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 🚀

@ima1zumi ima1zumi merged commit 0d66c33 into ruby:master Apr 29, 2024
40 checks passed
@tompng tompng deleted the fix_read_eof_terminated_input branch April 29, 2024 13:58
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.

2 participants