Skip to content

Commit ad6faad

Browse files
authored
Fix scrolldown condition in dialog rendering (#541)
1 parent 3cd50a6 commit ad6faad

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/reline/line_editor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ def add_dialog_proc(name, p, context = nil)
724724
ymax = ymax.clamp(screen_y_range.begin, screen_y_range.end)
725725
dialog_y = @first_line_started_from + @started_from
726726
cursor_y = dialog_y
727-
if @highest_in_all < ymax
727+
if @highest_in_all <= ymax
728728
scroll_down(ymax - cursor_y)
729729
move_cursor_up(ymax - cursor_y)
730730
end

test/reline/yamatanooroti/test_rendering.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,25 @@ def test_simple_dialog_at_right_edge
957957
EOC
958958
end
959959

960+
def test_dialog_scroll_pushup_condition
961+
start_terminal(10, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
962+
write("\n" * 10)
963+
write("if 1\n sSt\nend")
964+
write("\C-p\C-h\C-e")
965+
assert_screen(<<~'EOC')
966+
prompt>
967+
prompt>
968+
prompt>
969+
prompt>
970+
prompt>
971+
prompt>
972+
prompt> if 1
973+
prompt> St
974+
prompt> enString
975+
Struct
976+
EOC
977+
end
978+
960979
def test_simple_dialog_with_scroll_screen
961980
start_terminal(5, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog simple}, startup_message: 'Multiline REPL.')
962981
write("if 1\n 2\n 3\n 4\n 5\n 6")

0 commit comments

Comments
 (0)