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 dialog corrupts rendering by pushing up input line too much #524

Conversation

tompng
Copy link
Member

@tompng tompng commented Mar 24, 2023

Description

Fix this redering corrupt bug.
Left: before, Right: after

dialog_range.mp4

Problem

If the terminal height is 5

prompt > 1 + 2
=> 3
prompt> if 1
prompt>   2.

Reline can only render 3 lines of dialog if the cursor is on line 2.

prompt> if 1
prompt>   2.
          2.remeinder
          2.abs
          2.magnitude

If reline breaks this rule and render 4 lines

prompt>   2.
          2.remeinder
          2.abs
          2.magnitude
          2.zero?

Reline cannot move cursor to the beginning of line, where if 1 was displayed.
This is making reline's rendering corrupt.
I changed dialog rendering not to render where it overflows screen.

@tompng tompng force-pushed the rewrite_dialog_rendering_with_dialog_screen_overflow branch 2 times, most recently from a925ff4 to cc585ee Compare March 29, 2023 17:11
@tompng tompng force-pushed the rewrite_dialog_rendering_with_dialog_screen_overflow branch from cc585ee to 3206d10 Compare May 1, 2023 12:35
@tompng tompng marked this pull request as ready for review May 1, 2023 12:41
@st0012
Copy link
Member

st0012 commented May 1, 2023

This is good, but would it be possible to make it not push at all?

Like in this example, can the completion dialog not pushing away the previous output? Since we supports scrolling and there's still plenty of space below the input line, I'd imagine the dialog to use only the empty space.

Screen.Recording.2023-05-01.at.13.52.47.mov

@tompng
Copy link
Member Author

tompng commented May 1, 2023

I think not pushing up at all is hard. In this case, we have to push up to show completion dialog.
スクリーンショット 2023-05-01 22 17 01

My idea to mitigate pushing up problem is to limit the completion dialog height to (screen_height / 2) or something.
Dialog users(including reline itself for internal use like completion dialog) should specify an appropriate dialog size.
But this pull request only aims reline to work without corrupting the screen even if user specified inappropriate dialog size(ex: overflowing screen)

lib/reline/line_editor.rb Outdated Show resolved Hide resolved
lib/reline/line_editor.rb Show resolved Hide resolved
@st0012 st0012 added the bug Something isn't working label May 1, 2023
Co-authored-by: Stan Lo <stan001212@gmail.com>
@st0012 st0012 merged commit bc0e3d1 into ruby:master May 7, 2023
matzbot pushed a commit to ruby/ruby that referenced this pull request May 7, 2023
too much
(ruby/reline#524)

* Do not render dialog where it overflows screen

* Dialog rendering should Scroll down only when needed

* Refactor screen_y_range calculation

Co-authored-by: Stan Lo <stan001212@gmail.com>

---------

ruby/reline@bc0e3d1310

Co-authored-by: Stan Lo <stan001212@gmail.com>
@tompng tompng deleted the rewrite_dialog_rendering_with_dialog_screen_overflow branch May 7, 2023 15:10
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