зеркало из https://github.com/github/ruby.git
[ruby/reline] Use appropriate dialog height and reduce screen pushup
problem (https://github.com/ruby/reline/pull/542) * Provide preferred_dialog_height for dialog positioning * Fix rendering test
This commit is contained in:
Родитель
bf1bc5362e
Коммит
5d137a7f77
|
@ -260,7 +260,7 @@ module Reline
|
|||
pos: cursor_pos_to_render,
|
||||
contents: result,
|
||||
scrollbar: true,
|
||||
height: 15,
|
||||
height: [15, preferred_dialog_height].min,
|
||||
bg_color: 46,
|
||||
pointer_bg_color: 45,
|
||||
fg_color: 37,
|
||||
|
|
|
@ -562,6 +562,16 @@ class Reline::LineEditor
|
|||
@line_editor.instance_variable_get(:@screen_size).last
|
||||
end
|
||||
|
||||
def screen_height
|
||||
@line_editor.instance_variable_get(:@screen_size).first
|
||||
end
|
||||
|
||||
def preferred_dialog_height
|
||||
rest_height = @line_editor.instance_variable_get(:@rest_height)
|
||||
scroll_partial_screen = @line_editor.instance_variable_get(:@scroll_partial_screen) || 0
|
||||
[cursor_pos.y - scroll_partial_screen, rest_height, (screen_height + 6) / 5].max
|
||||
end
|
||||
|
||||
def completion_journey_data
|
||||
@line_editor.instance_variable_get(:@completion_journey_data)
|
||||
end
|
||||
|
|
|
@ -1365,21 +1365,21 @@ begin
|
|||
|
||||
def test_scroll_at_bottom_for_dialog
|
||||
start_terminal(10, 40, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
|
||||
write("\n\n\n\n\n\n")
|
||||
write("def hoge\n\n\n\n\n\n\nend\C-p\C-p\C-p\C-e")
|
||||
write("\n\n\n\n\n\n\n\n\n\n\n")
|
||||
write("def hoge\n\nend\C-p\C-e")
|
||||
write(" S")
|
||||
close
|
||||
assert_screen(<<~'EOC')
|
||||
prompt>
|
||||
prompt>
|
||||
prompt>
|
||||
prompt>
|
||||
prompt>
|
||||
prompt> def hoge
|
||||
prompt>
|
||||
prompt>
|
||||
prompt>
|
||||
prompt> S
|
||||
prompt> String
|
||||
prompt> Struct
|
||||
prompt> enSymbol
|
||||
ScriptError
|
||||
SyntaxError
|
||||
prompt> enString █
|
||||
Struct ▀
|
||||
Symbol
|
||||
EOC
|
||||
end
|
||||
|
||||
|
@ -1433,30 +1433,35 @@ begin
|
|||
|
||||
def test_clear_dialog_when_just_move_cursor_at_last_line
|
||||
start_terminal(10, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
|
||||
write("class A\n 3\nend\n")
|
||||
write("\C-p\C-p\C-p\C-e\C-hS")
|
||||
write("class A\n 3\nend\n\n\n")
|
||||
write("\C-p\C-p\C-e; S")
|
||||
write("\C-n")
|
||||
write("1")
|
||||
write(";")
|
||||
close
|
||||
assert_screen(<<~'EOC')
|
||||
prompt> 3
|
||||
prompt> end
|
||||
=> 3
|
||||
prompt> class S
|
||||
prompt> 31
|
||||
prompt> end
|
||||
prompt>
|
||||
prompt>
|
||||
prompt> class A
|
||||
prompt> 3; S
|
||||
prompt> end;
|
||||
EOC
|
||||
end
|
||||
|
||||
def test_clear_dialog_when_adding_new_line_to_end_of_buffer
|
||||
start_terminal(10, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
|
||||
write("class A\n def a\n 3\n end\nend")
|
||||
write("class A\n def a\n 3\n 3\n end\nend")
|
||||
write("\n")
|
||||
write("class S")
|
||||
write("\n")
|
||||
write(" 3")
|
||||
close
|
||||
assert_screen(<<~'EOC')
|
||||
prompt> def a
|
||||
prompt> 3
|
||||
prompt> 3
|
||||
prompt> end
|
||||
prompt> end
|
||||
=> :a
|
||||
|
@ -1474,6 +1479,7 @@ begin
|
|||
write(" 3")
|
||||
close
|
||||
assert_screen(<<~'EOC')
|
||||
prompt> 3
|
||||
prompt> end
|
||||
prompt> end
|
||||
=> :a
|
||||
|
|
Загрузка…
Ссылка в новой задаче