summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2020-12-19 00:41:00 +0900
committeraycabta <aycabta@gmail.com>2020-12-19 02:12:11 +0900
commitc2a5594e271170b57f92d7461466f3c0ab8da863 (patch)
treeef4ae3d3792c9167c117ef5a31cd160cb1be6b7a /lib
parentd4257c6152ac9ad5179eb77d6e68942a5b9c011f (diff)
[ruby/reline] Use cached prompt list when just moved the cursor
https://github.com/ruby/reline/commit/cfe619460b
Diffstat (limited to 'lib')
-rw-r--r--lib/reline/line_editor.rb10
1 files changed, 9 insertions, 1 deletions
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)