From c2a5594e271170b57f92d7461466f3c0ab8da863 Mon Sep 17 00:00:00 2001 From: aycabta Date: Sat, 19 Dec 2020 00:41:00 +0900 Subject: [PATCH] [ruby/reline] Use cached prompt list when just moved the cursor https://github.com/ruby/reline/commit/cfe619460b --- lib/reline/line_editor.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index f33b22852d..3637941209 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -80,7 +80,15 @@ class Reline::LineEditor end return [prompt, calculate_width(prompt, true), [prompt] * buffer.size] if simplified_rendering? if @prompt_proc - if @cached_prompt_list and Time.now.to_f < (@prompt_cache_time + PROMPT_LIST_CACHE_TIMEOUT) and buffer.size == @cached_prompt_list.size + use_cached_prompt_list = false + if @cached_prompt_list + if @just_cursor_moving + use_cached_prompt_list = true + elsif Time.now.to_f < (@prompt_cache_time + PROMPT_LIST_CACHE_TIMEOUT) and buffer.size == @cached_prompt_list.size + use_cached_prompt_list = true + end + end + if use_cached_prompt_list prompt_list = @cached_prompt_list else prompt_list = @cached_prompt_list = @prompt_proc.(buffer)