Module: Complete

Defined in:
lib/droxi/complete.rb

Overview

Module containing tab-completion logic and methods.

Class Method Summary collapse

Class Method Details

.complete(line, state) ⇒ Object

Return an Array of completion options for the given input line and client state.



8
9
10
11
12
13
14
15
16
# File 'lib/droxi/complete.rb', line 8

def self.complete(line, state)
  tokens = Text.tokenize(line, include_empty: true)
  type = completion_type(tokens)
  completion_options(type, tokens.last, state).map do |option|
    option.gsub(' ', '\ ').sub(/\\ $/, ' ')
      .split.drop(tokens.last.count(' ')).join(' ')
      .sub(/[^\\\/]$/, '\0 ')
  end
end