ruby-changes:63946
From: aycabta <ko1@a...>
Date: Sat, 5 Dec 2020 03:09:44 +0900 (JST)
Subject: [ruby-changes:63946] b763c5cdf0 (master): [ruby/reline] Stop rerendering if the cursor is only moved
https://git.ruby-lang.org/ruby.git/commit/?id=b763c5cdf0 From b763c5cdf09fab247a7ca9526bb27a63cf03a81d Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Fri, 20 Nov 2020 17:13:15 +0900 Subject: [ruby/reline] Stop rerendering if the cursor is only moved https://github.com/ruby/reline/commit/30e8eaf855 diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 543df2b..fc7e576 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -59,6 +59,8 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L59 def simplified_rendering? if finished? false + elsif @just_cursor_moving and not @rerender_all + true else not @rerender_all and not finished? and Reline::IOGate.in_pasting? end @@ -188,6 +190,7 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L190 @searching_prompt = nil @first_char = true @add_newline_to_end_of_buffer = false + @just_cursor_moving = false @eof = false @continuous_insertion_buffer = String.new(encoding: @encoding) reset_line @@ -335,6 +338,10 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L338 if @add_newline_to_end_of_buffer rerender_added_newline @add_newline_to_end_of_buffer = false + elsif @just_cursor_moving and not @rerender_all + just_move_cursor + @just_cursor_moving = false + return elsif @previous_line_index or new_highest_in_this != @highest_in_this rerender_changed_current_line @previous_line_index = nil @@ -382,6 +389,25 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L389 @previous_line_index = nil end + def just_move_cursor + prompt, prompt_width, prompt_list = check_multiline_prompt(@buffer_of_lines, prompt) + move_cursor_up(@started_from) + new_first_line_started_from = + if @line_index.zero? + 0 + else + calculate_height_by_lines(@buffer_of_lines[0..(@line_index - 1)], prompt_list || prompt) + end + @line = @buffer_of_lines[@line_index] + move_cursor_down(new_first_line_started_from - @first_line_started_from) + @first_line_started_from = new_first_line_started_from + calculate_nearest_cursor + @started_from = calculate_height_by_width(prompt_width + @cursor) - 1 + move_cursor_down(@started_from) + Reline::IOGate.move_cursor_column((prompt_width + @cursor) % @screen_size.last) + @previous_line_index = nil + end + private def rerender_changed_current_line if @previous_line_index new_lines = whole_lines(index: @previous_line_index, line: @line) @@ -923,6 +949,13 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L949 unless completion_occurs @completion_state = CompletionState::NORMAL end + unless Reline::IOGate.in_pasting? + if @previous_line_index and @buffer_of_lines[@previous_line_index] == @line + @just_cursor_moving = true + elsif @previous_line_index.nil? and @buffer_of_lines[@line_index] == @line + @just_cursor_moving = true + end + end if @is_multiline and @auto_indent_proc and not simplified_rendering? process_auto_indent end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/