1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/reline] Use cached prompt list when just moved the cursor

https://github.com/ruby/reline/commit/cfe619460b
This commit is contained in:
aycabta 2020-12-19 00:41:00 +09:00
parent d4257c6152
commit c2a5594e27

View file

@ -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)