diff options
author | aycabta <aycabta@gmail.com> | 2021-08-27 01:51:44 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2021-08-29 20:30:33 +0900 |
commit | 4b2b10707af564c1d600957a69d89165fa7d11f1 (patch) | |
tree | e34f0ed0c06d9f0a41b09eca1df3bf225613f1ff /lib/reline.rb | |
parent | 8e463e3e73e37ff57a5fde142436280846718ecf (diff) |
[ruby/reline] Implement dynamic selection of candidates
https://github.com/ruby/reline/commit/e46437df00
Diffstat (limited to 'lib/reline.rb')
-rw-r--r-- | lib/reline.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/reline.rb b/lib/reline.rb index a3f37d1ab0..eb99bd5931 100644 --- a/lib/reline.rb +++ b/lib/reline.rb @@ -183,7 +183,7 @@ module Reline end @dialog_proc = ->() { # autocomplete - if just_cursor_moving + if just_cursor_moving and completion_journey_data.nil? # Auto complete starts only when edited return nil end @@ -191,7 +191,14 @@ module Reline if target.nil? or target.empty? return nil end - result = call_completion_proc_with_checking_args(pre, target, post) + if completion_journey_data and completion_journey_data.list + result = completion_journey_data.list.dup + result.shift + pointer = completion_journey_data.pointer - 1 + else + result = call_completion_proc_with_checking_args(pre, target, post) + pointer = nil + end if result and result.size == 1 and result[0] == target result = nil end @@ -203,7 +210,7 @@ module Reline else y = 0 end - [Reline::CursorPos.new(x, y), result] + [Reline::CursorPos.new(x, y), result, pointer] } inner_readline(prompt, add_hist, true, &confirm_multiline_termination) |