1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/reline] Cut off the excess on narrow screen

972cc993ca
This commit is contained in:
aycabta 2021-10-06 02:56:14 +09:00 committed by git
parent a2f55679f0
commit 374b15a84a
2 changed files with 30 additions and 0 deletions

View file

@ -709,6 +709,10 @@ class Reline::LineEditor
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)

View file

@ -1072,6 +1072,32 @@ begin
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')