Skip to content

Fix rendering bug of nomultiline prompt - #730

Merged
tompng merged 1 commit into
ruby:masterfrom
tompng:print_nomultiline_prompt_bugfix
Jul 12, 2024
Merged

tompng merged 1 commit into
ruby:masterfrom
tompng:print_nomultiline_prompt_bugfix

Conversation

@tompng

@tompng tompng commented Jul 11, 2024 •

Copy link
Copy Markdown
Member

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

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants