@@ -59,6 +59,8 @@ def initialize(config, encoding)
59
59
def simplified_rendering?
60
60
if finished?
61
61
false
62
+ elsif @just_cursor_moving and not @rerender_all
63
+ true
62
64
else
63
65
not @rerender_all and not finished? and Reline ::IOGate . in_pasting?
64
66
end
@@ -188,6 +190,7 @@ def reset_variables(prompt = '', encoding:)
188
190
@searching_prompt = nil
189
191
@first_char = true
190
192
@add_newline_to_end_of_buffer = false
193
+ @just_cursor_moving = false
191
194
@eof = false
192
195
@continuous_insertion_buffer = String . new ( encoding : @encoding )
193
196
reset_line
@@ -335,6 +338,10 @@ def rerender
335
338
if @add_newline_to_end_of_buffer
336
339
rerender_added_newline
337
340
@add_newline_to_end_of_buffer = false
341
+ elsif @just_cursor_moving and not @rerender_all
342
+ just_move_cursor
343
+ @just_cursor_moving = false
344
+ return
338
345
elsif @previous_line_index or new_highest_in_this != @highest_in_this
339
346
rerender_changed_current_line
340
347
@previous_line_index = nil
@@ -382,6 +389,25 @@ def rerender
382
389
@previous_line_index = nil
383
390
end
384
391
392
+ def just_move_cursor
393
+ prompt , prompt_width , prompt_list = check_multiline_prompt ( @buffer_of_lines , prompt )
394
+ move_cursor_up ( @started_from )
395
+ new_first_line_started_from =
396
+ if @line_index . zero?
397
+ 0
398
+ else
399
+ calculate_height_by_lines ( @buffer_of_lines [ 0 ..( @line_index - 1 ) ] , prompt_list || prompt )
400
+ end
401
+ @line = @buffer_of_lines [ @line_index ]
402
+ move_cursor_down ( new_first_line_started_from - @first_line_started_from )
403
+ @first_line_started_from = new_first_line_started_from
404
+ calculate_nearest_cursor
405
+ @started_from = calculate_height_by_width ( prompt_width + @cursor ) - 1
406
+ move_cursor_down ( @started_from )
407
+ Reline ::IOGate . move_cursor_column ( ( prompt_width + @cursor ) % @screen_size . last )
408
+ @previous_line_index = nil
409
+ end
410
+
385
411
private def rerender_changed_current_line
386
412
if @previous_line_index
387
413
new_lines = whole_lines ( index : @previous_line_index , line : @line )
@@ -923,6 +949,13 @@ def input_key(key)
923
949
unless completion_occurs
924
950
@completion_state = CompletionState ::NORMAL
925
951
end
952
+ unless Reline ::IOGate . in_pasting?
953
+ if @previous_line_index and @buffer_of_lines [ @previous_line_index ] == @line
954
+ @just_cursor_moving = true
955
+ elsif @previous_line_index . nil? and @buffer_of_lines [ @line_index ] == @line
956
+ @just_cursor_moving = true
957
+ end
958
+ end
926
959
if @is_multiline and @auto_indent_proc and not simplified_rendering?
927
960
process_auto_indent
928
961
end
0 commit comments