Skip to content

Commit

Permalink
[ruby/reline] Use cached prompt list when just moved the cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Dec 18, 2020
1 parent d4257c6 commit c2a5594
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/reline/line_editor.rb
Expand Up @@ -80,7 +80,15 @@ def simplified_rendering?
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)
Expand Down

0 comments on commit c2a5594

Please sign in to comment.