run
reset
resize 40 10
set_autocomplete_2
----
TEA WINDOW SIZE: {40 10}
-- view:
> [7m [0m                                   ␤
M-? toggle key help • C-d erase/stop🛇

# No context brings up full completion menu.
run
key tab
----
TEA PRINT: {We're matching ""!}
-- view:
[;mnames[0m        ␤
 Alice       ␤
 Amanda      ␤
             ␤
  1/50       ␤
(entry "Alice" has no description)␤
> [7m [0m                                   ␤
M-? toggle key help • C-c close/cancel🛇

# If we press "/" during the menu, a filter comes up.
run
key /
----
-- view:
Filter: [7m [0m    ␤
 Alice       ␤
 Amanda      ␤
             ␤
  1/50       ␤
(entry "Alice" has no description)␤
> [7m [0m                                   ␤
M-? toggle key help • C-c close/cancel🛇

# Entering text at the filter filters down the list.
run
type thur
----
-- view:
Filter: hur[7m [0m ␤
 Arthur      ␤
             ␤
             ␤
             ␤
(entry "Arthur" has no description)␤
> [7m [0m                                   ␤
M-? toggle key help • C-c close/cancel🛇

# Pressing enter makes the filter disappear and
# keeps the selection.
run
enter
----
-- view:
[;mnames[0m        ␤
 Arthur      ␤
             ␤
             ␤
             ␤
(entry "Arthur" has no description)␤
> [7m [0m                                   ␤
M-? toggle key help • C-c close/cancel🛇

# If we press enter during the menu, this selects
# the current entry.
run
key enter
----
-- view:
> Arthur [7m [0m                            ␤
M-? toggle key help • C-d erase/stop🛇

# Verify that if no entry is selected, nothing bad happens
# (regression test for an earlier display bug)
run
key tab
key /
type invalid
----
TEA PRINT: {We're matching ""!}
-- view:
Filter: lid[7m [0m␤
            ␤
            ␤
            ␤
            ␤
(no entry seleted)␤
> Arthur [7m [0m                            ␤
M-? toggle key help • C-c close/cancel🛇

# With a prefix, the completion list is pre-filtered.
run
reset
type b
key tab
----
TEA PRINT: {We're matching "B"!}
-- view:
[;mnames[0m …  ␤
 Barbara ␤
 Betty   ␤
 Brenda  ␤
 Brian   ␤
         ␤
         ␤
(entry "Barbara" has no description)␤
> B[7m [0m                                   ␤
M-? toggle key help • C-c close/cancel🛇

# We can hide/show more key help.
run
key alt+?
----
-- view:
[;mnames[0m …  ␤
 Barbara ␤
 Betty   ␤
 Brenda  ␤
 Brian   ␤
         ␤
         ␤
(entry "Barbara" has no description)␤
> B[7m [0m                                   ␤
→/M-n         next column     ␤
←/M-p         prev column     ␤
C-j/enter/tab accept          ␤
C-c           close/cancel    🛇


run
key alt+?
----
-- view:
[;mnames[0m …  ␤
 Barbara ␤
 Betty   ␤
 Brenda  ␤
 Brian   ␤
         ␤
         ␤
(entry "Barbara" has no description)␤
> B[7m [0m                                   ␤
M-? toggle key help • C-c close/cancel🛇

# Completion is canceled without input upon ctrl+c.
run
key ctrl+c
----
-- view:
> B[7m [0m                                   ␤
M-? toggle key help • C-d erase/stop🛇

# If the pre-filtered list of completions contains a prefix longer
# than the current input, that prefix is pre-entered even as the
# completion list is displayed.
run
reset
type chr
key tab
----
TEA PRINT: {We're matching "Chr"!}
-- view:
[;mnames[0m        ␤
 Christine   ␤
 Christopher ␤
             ␤
             ␤
(entry "Christine" has no description)␤
> Christ[7m [0m                              ␤
M-? toggle key help • C-c close/cancel🛇

# After a completion is selected, it appends to the pre-filled prefix.
run
key down
key enter
----
-- view:
> Christopher [7m [0m                        ␤
M-? toggle key help • C-d erase/stop🛇

# That prefilled common prefix is also preserved when ctrl+c is
# pressed.
run
reset
type chr
key tab
key ctrl+c
----
TEA PRINT: {We're matching "Chr"!}
-- view:
> Christ[7m [0m                              ␤
M-? toggle key help • C-d erase/stop🛇
