Skip to content

Commit 7760c43

Browse files
committed
Do not render dialog where it overflows screen
1 parent e672ae3 commit 7760c43

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/reline/line_editor.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,9 @@ def add_dialog_proc(name, p, context = nil)
714714

715715
Reline::IOGate.hide_cursor
716716
ymin, ymax = (ranges_to_restore.keys + new_dialog_ranges.keys).minmax
717+
screen_y_range = (@scroll_partial_screen || 0)..(@scroll_partial_screen || 0) + @screen_height - 1
718+
ymin = ymin.clamp(screen_y_range.begin, screen_y_range.end)
719+
ymax = ymax.clamp(screen_y_range.begin, screen_y_range.end)
717720
dialog_y = @first_line_started_from + @started_from
718721
cursor_y = dialog_y
719722
scroll_down(ymax - cursor_y)

test/reline/yamatanooroti/test_rendering.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,12 +1319,12 @@ def test_scroll_at_bottom_for_dialog
13191319
prompt>
13201320
prompt>
13211321
prompt>
1322+
prompt> S
13221323
prompt> String
13231324
prompt> Struct
1324-
prompt> Symbol
1325-
prompt> enScriptError
1325+
prompt> enSymbol
1326+
ScriptError
13261327
SyntaxError
1327-
Signal
13281328
EOC
13291329
end
13301330

0 commit comments

Comments
 (0)