Skip to content

Commit

Permalink
[ruby/reline] Fix scrolldown condition in dialog rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng authored and matzbot committed May 27, 2023
1 parent 5d137a7 commit cf0b9e0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/reline/line_editor.rb
Expand Up @@ -724,7 +724,7 @@ def add_dialog_proc(name, p, context = nil)
ymax = ymax.clamp(screen_y_range.begin, screen_y_range.end)
dialog_y = @first_line_started_from + @started_from
cursor_y = dialog_y
if @highest_in_all < ymax
if @highest_in_all <= ymax
scroll_down(ymax - cursor_y)
move_cursor_up(ymax - cursor_y)
end
Expand Down
19 changes: 19 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Expand Up @@ -957,6 +957,25 @@ def test_simple_dialog_at_right_edge
EOC
end

def test_dialog_scroll_pushup_condition
start_terminal(10, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
write("\n" * 10)
write("if 1\n sSt\nend")
write("\C-p\C-h\C-e")
assert_screen(<<~'EOC')
prompt>
prompt>
prompt>
prompt>
prompt>
prompt>
prompt> if 1
prompt> St
prompt> enString
Struct
EOC
end

def test_simple_dialog_with_scroll_screen
start_terminal(5, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog simple}, startup_message: 'Multiline REPL.')
write("if 1\n 2\n 3\n 4\n 5\n 6")
Expand Down

0 comments on commit cf0b9e0

Please sign in to comment.