lib/tty/reader/completer.rb
def complete_next(line, direction: :next)
        return if completions.empty?

        previous_suggestion = completions.get
        first_or_last = direction == :previous ? :first? : :last?
        if completions.send(first_or_last) && !@show_initial
          @show_initial = true
          completed_word = word
        else
          if @show_initial
            @show_initial = false
            previous_suggestion = word
          end
          completions.send(direction)
          completed_word = completions.get
        end

        length_to_remove = previous_suggestion.length
        length_to_remove += suffix.length if previous_suggestion != word

        line.remove(length_to_remove)
        line.insert("#{completed_word}#{suffix unless @show_initial}")

        completed_word
      end
# Complete a word with the next suggestion from completions
#
# @param [Line] line
#   the line to complete a word in
# @param [Symbol] direction
#   the direction in which to cycle through completions
#
# @return [String, nil]
#   the completed word or nil when no suggestion is found
#
# @api public
Complete a word with the next suggestion from completions
Complete a word with the next suggestion from completions
def complete_next(line, direction: :next)
        return if completions.empty?
        previous_suggestion = completions.get
        first_or_last = direction == :previous ? :first? : :last?
        if completions.send(first_or_last) && !@show_initial
          @show_initial = true
          completed_word = word
        else
          if @show_initial
            @show_initial = false
            previous_suggestion = word
          end
          completions.send(direction)
          completed_word = completions.get
        end
        length_to_remove = previous_suggestion.length
        length_to_remove += suffix.length if previous_suggestion != word
        line.remove(length_to_remove)
        line.insert("#{completed_word}#{suffix unless @show_initial}")
        completed_word
      end
def complete_next ( line , direction : :next ) return if completions . empty? previous_suggestion = completions . get first_or_last = direction == :previous ? :first? : :last? if completions . send ( first_or_last ) && ! @show_initial @show_initial = true completed_word = word else if @show_initial @show_initial = false previous_suggestion = word end completions . send ( direction ) completed_word = completions . get end length_to_remove = previous_suggestion . length length_to_remove += suffix . length if previous_suggestion != word line . remove ( length_to_remove ) line . insert ( "#{completed_word}#{suffix unless @show_initial}" ) completed_word end
Complete a word with the next suggestion from completions
Complete a word with the next suggestion from completions
the completed word or nil when no suggestion is found
the completed word or nil when no suggestion is found
String, nil
line
direction
direction the direction in which to cycle through completions
direction the direction in which to cycle through completions
api
None