From fcca39fa73607e6acf2aea00fd8bf746023955dc Mon Sep 17 00:00:00 2001 From: aycabta Date: Thu, 30 May 2019 18:20:59 +0900 Subject: Fix strange vertical cursor moving when adding a newline at bottom --- lib/reline/line_editor.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index e84d087ac1..805053fbff 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -360,8 +360,12 @@ class Reline::LineEditor back = 0 modify_lines(new_lines).each_with_index do |line, index| height = render_partial(prompt, prompt_width, line, false) - move_cursor_down(1) - back += height + if index < (new_lines.size - 1) + scroll_down(1) + back += height + else + back += height - 1 + end end move_cursor_up(back) if @previous_line_index -- cgit v1.2.3