howl.interactions.select_line

local buffer, editor

before_each ->
  app.window = Window!
  app.window\realize!
  buffer = Buffer!
  buffer.text = 'one\ntwo\nthree'
  editor = Editor buffer

registers interactions

assert.not_nil interact.select_line

interact.select_line

shows opt.lines in the completion list by default

local lines
within_command_line (-> interact.select_line(:editor, lines: buffer.lines)), (command_line) ->
  lines = list_items command_line, 2
assert.same {'one', 'two', 'three'}, lines

filters lines to match text entered

lines = {}
within_command_line (-> interact.select_line(:editor, lines: buffer.lines)), (command_line) ->
  append lines, list_items command_line, 2
  command_line\write 'o'
  append lines, list_items command_line, 2
  command_line\write 'n'
  append lines, list_items command_line, 2
  command_line\clear!
  command_line\write ''
  append lines, list_items command_line, 2

assert.same {'one', 'two', 'three'}, lines[1]
assert.same {'one', 'two'}, lines[2]
assert.same {'one'}, lines[3]
assert.same {'one', 'two', 'three'}, lines[4]