diff options
author | aycabta <[email protected]> | 2022-01-07 22:59:55 +0900 |
---|---|---|
committer | git <[email protected]> | 2022-01-16 22:09:29 +0900 |
commit | 2bc6b07a8d313b6aa9dea13d81ffd3c97db84ead (patch) | |
tree | 23180c35d128e8cc35da0de64f799b17c34189d0 /lib/reline/line_editor.rb | |
parent | f94a2adf6a45e93d12c63a9b4ef3e21d9b7e5063 (diff) |
[ruby/reline] Combine common logic into one
https://github.com/ruby/reline/commit/5db9738f17
Diffstat (limited to 'lib/reline/line_editor.rb')
-rw-r--r-- | lib/reline/line_editor.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 295af526fe..70be8ac27a 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -466,20 +466,12 @@ class Reline::LineEditor 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 @@ -892,6 +884,14 @@ class Reline::LineEditor 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 |