Skip to content

Commit

Permalink
[ruby/reline] Combine common logic into one
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta authored and matzbot committed Jan 16, 2022
1 parent f94a2ad commit 2bc6b07
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,20 +466,12 @@ def rerender
new_highest_in_this = calculate_height_by_width(prompt_width + calculate_width(@line.nil? ? '' : @line))
rendered = false
if @add_newline_to_end_of_buffer
@dialogs.each do |dialog|
clear_each_dialog(dialog)
dialog.contents = nil
dialog.trap_key = nil
end
clear_dialog_with_content
rerender_added_newline(prompt, prompt_width)
@add_newline_to_end_of_buffer = false
else
if @just_cursor_moving and not @rerender_all
@dialogs.each do |dialog|
clear_each_dialog(dialog)
dialog.contents = nil
dialog.trap_key = nil
end
clear_dialog_with_content
rendered = just_move_cursor
@just_cursor_moving = false
return
Expand Down Expand Up @@ -892,6 +884,14 @@ def add_dialog_proc(name, p, context = nil)
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)
dialog.trap_key = nil
return unless dialog.contents
Expand Down

0 comments on commit 2bc6b07

Please sign in to comment.