From f8732bd4d65cf0b776348907b56bd58f4f79ca9c Mon Sep 17 00:00:00 2001 From: aycabta Date: Wed, 22 May 2019 02:52:29 +0900 Subject: [PATCH] Reline#reset should initalize @rest_height and @screen_size eveytime --- lib/reline/line_editor.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 6c7c5bdd38..95d7c925b2 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -81,10 +81,16 @@ class Reline::LineEditor def initialize(config) @config = config - reset + reset_variables end def reset(prompt = '', encoding = Encoding.default_external) + @rest_height = (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y + @screen_size = Reline::IOGate.get_screen_size + reset_variables(prompt, encoding) + end + + def reset_variables(prompt = '', encoding = Encoding.default_external) @prompt = prompt @encoding = encoding @prompt_width = calculate_width(@prompt) @@ -236,8 +242,6 @@ class Reline::LineEditor end def rerender # TODO: support physical and logical lines - @rest_height ||= (Reline::IOGate.get_screen_size.first - 1) - Reline::IOGate.cursor_pos.y - @screen_size ||= Reline::IOGate.get_screen_size if @menu_info @output.puts @menu_info.list.each do |item|