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

[ruby/reline] Combine common logic into one

5db9738f17
This commit is contained in:
aycabta 2022-01-07 22:59:55 +09:00 committed by git
parent f94a2adf6a
commit 2bc6b07a8d

View file

@ -466,20 +466,12 @@ class Reline::LineEditor
new_highest_in_this = calculate_height_by_width(prompt_width + calculate_width(@line.nil? ? '' : @line)) new_highest_in_this = calculate_height_by_width(prompt_width + calculate_width(@line.nil? ? '' : @line))
rendered = false rendered = false
if @add_newline_to_end_of_buffer if @add_newline_to_end_of_buffer
@dialogs.each do |dialog| clear_dialog_with_content
clear_each_dialog(dialog)
dialog.contents = nil
dialog.trap_key = nil
end
rerender_added_newline(prompt, prompt_width) rerender_added_newline(prompt, prompt_width)
@add_newline_to_end_of_buffer = false @add_newline_to_end_of_buffer = false
else else
if @just_cursor_moving and not @rerender_all if @just_cursor_moving and not @rerender_all
@dialogs.each do |dialog| clear_dialog_with_content
clear_each_dialog(dialog)
dialog.contents = nil
dialog.trap_key = nil
end
rendered = just_move_cursor rendered = just_move_cursor
@just_cursor_moving = false @just_cursor_moving = false
return return
@ -892,6 +884,14 @@ class Reline::LineEditor
end end
end end
private def clear_dialog_with_content
@dialogs.each do |dialog|
clear_each_dialog(dialog)
dialog.contents = nil
dialog.trap_key = nil
end
end
private def clear_each_dialog(dialog) private def clear_each_dialog(dialog)
dialog.trap_key = nil dialog.trap_key = nil
return unless dialog.contents return unless dialog.contents