ruby-changes:67308
From: aycabta <ko1@a...>
Date: Sun, 29 Aug 2021 20:30:45 +0900 (JST)
Subject: [ruby-changes:67308] fdc005e54e (master): [ruby/reline] Completion journey starts with one of candidates
https://git.ruby-lang.org/ruby.git/commit/?id=fdc005e54e From fdc005e54e58bbf005381bcfc7ac59d56fb05aac Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Fri, 27 Aug 2021 01:47:33 +0900 Subject: [ruby/reline] Completion journey starts with one of candidates First one is just original string. https://github.com/ruby/reline/commit/ccb70cc240 --- lib/reline/line_editor.rb | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 5d7095b..b449f4f 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -1176,6 +1176,16 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L1176 @completion_journey_data = CompletionJourneyData.new( preposing, postposing, [target] + list.select{ |item| item.start_with?(target) }, 0) + if @completion_journey_data.list.size == 1 + @completion_journey_data.pointer = 0 + else + case direction + when :up + @completion_journey_data.pointer = @completion_journey_data.list.size - 1 + when :down + @completion_journey_data.pointer = 1 + end + end @completion_state = CompletionState::JOURNEY else case direction @@ -1190,13 +1200,13 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L1200 @completion_journey_data.pointer = 0 end end - completed = @completion_journey_data.list[@completion_journey_data.pointer] - @line = @completion_journey_data.preposing + completed + @completion_journey_data.postposing - line_to_pointer = @completion_journey_data.preposing + completed - @cursor_max = calculate_width(@line) - @cursor = calculate_width(line_to_pointer) - @byte_pointer = line_to_pointer.bytesize end + completed = @completion_journey_data.list[@completion_journey_data.pointer] + @line = @completion_journey_data.preposing + completed + @completion_journey_data.postposing + line_to_pointer = @completion_journey_data.preposing + completed + @cursor_max = calculate_width(@line) + @cursor = calculate_width(line_to_pointer) + @byte_pointer = line_to_pointer.bytesize end private def run_for_operators(key, method_symbol, &block) -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/