Skip to content

Commit

Permalink
Cut off the excess on narrow screen
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Oct 5, 2021
1 parent 996bfec commit 972cc99
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,10 @@ def add_dialog_proc(name, p, context = nil)
end
Reline::IOGate.hide_cursor
dialog.width += @block_elem_width if dialog.scrollbar_pos
if dialog.column < 0
dialog.column = 0
dialog.width = @screen_size.last
end
reset_dialog(dialog, old_dialog)
move_cursor_down(dialog.vertical_offset)
Reline::IOGate.move_cursor_column(dialog.column)
Expand Down
26 changes: 26 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,32 @@ def test_dialog_callback_returns_nil
EOC
end

def test_dialog_narrower_than_screen
start_terminal(20, 11, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete-long}, startup_message: 'Multiline REPL.')
write('S' + "\C-i" * 3)
close
assert_screen(<<~'EOC')
Multiline R
EPL.
prompt> Sym
String
Struct █
Symbol █
StopIterat█
SystemCall█
SystemExit█
SystemStac█
ScriptErro█
SyntaxErro█
Signal █
SizedQueue█
Set
SecureRand
Socket
StringIO
EOC
end

def test_rerender_argument_prompt_after_pasting
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
write('abcdef')
Expand Down

0 comments on commit 972cc99

Please sign in to comment.