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 rendering bug of nomultiline prompt #730

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

tompng
Copy link
Member

@tompng tompng commented Jul 11, 2024

Fix bug of print('a'*10); Reline.readline('>') wrong rendering

Readline prints prompt before any other escape sequence, which is ensured in readline-ext test. Reline follows this in singleline mode.

Just after printing prompt, Reline sets @rendered_screen.lines = [[[0, prompt_width, prompt]]] representing that prompt is rendered in column 0.

But in this case

Reline.readline 'prompt1>'
print 'foo'
Reline.readline 'bar>'
# screen is `foob█ar>`

foobar> is rendered in terminal screen. bar> is not rendered in column 0.

# After this fix
print 'foo'
Reline.readline 'bar>'
# prints `"bar>"` for compatibility with readline. This step is not needed for usability at all.
# clears current line and renders "bar>" on column 0
# screen is `bar>█`

@tompng tompng force-pushed the print_nomultiline_prompt_bugfix branch from b89be82 to e146ccc Compare July 11, 2024 17:43
Fix bug of `print('a'*10); Reline.readline('>')` wrong rendering
@tompng tompng force-pushed the print_nomultiline_prompt_bugfix branch from e146ccc to 8c157ed Compare July 11, 2024 18:01
@st0012 st0012 added the bug Something isn't working label Jul 11, 2024
Copy link
Member

@st0012 st0012 left a comment

Choose a reason for hiding this comment

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

Can confirm it fixed the weird behaviour, and at the same time makes the code a lot simpler ❤️

@tompng tompng merged commit c0469a1 into ruby:master Jul 12, 2024
40 checks passed
@tompng tompng deleted the print_nomultiline_prompt_bugfix branch July 12, 2024 12:21
matzbot pushed a commit to ruby/ruby that referenced this pull request Jul 12, 2024
(ruby/reline#730)

Fix bug of `print('a'*10); Reline.readline('>')` wrong rendering

ruby/reline@c0469a12b9
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