2020-06-08 15:16:09 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from pexpect_helper import SpawnedProc
|
2019-11-01 12:21:49 +00:00
|
|
|
|
2020-06-08 15:16:09 +00:00
|
|
|
sp = SpawnedProc()
|
2022-06-03 00:25:36 +00:00
|
|
|
send, sendline, sleep, expect_prompt, expect_re, expect_str = (
|
2020-06-08 15:32:56 +00:00
|
|
|
sp.send,
|
|
|
|
sp.sendline,
|
|
|
|
sp.sleep,
|
|
|
|
sp.expect_prompt,
|
|
|
|
sp.expect_re,
|
2022-06-03 00:25:36 +00:00
|
|
|
sp.expect_str,
|
2020-06-08 15:32:56 +00:00
|
|
|
)
|
2020-06-08 15:16:09 +00:00
|
|
|
expect_prompt()
|
|
|
|
|
2022-06-03 00:25:36 +00:00
|
|
|
# Verify COMPLETE_AUTO_SPACE behavior
|
|
|
|
sendline("complete -x -c monster -a truck")
|
|
|
|
expect_prompt()
|
|
|
|
sendline("complete -x -c monster -a energy=")
|
|
|
|
expect_prompt()
|
|
|
|
send("monster t")
|
|
|
|
sleep(0.1)
|
|
|
|
send("\t")
|
|
|
|
sleep(0.1)
|
|
|
|
send("!")
|
|
|
|
expect_str("monster truck !") # space
|
|
|
|
send("\b" * 64)
|
|
|
|
send("monster e")
|
|
|
|
sleep(0.1)
|
|
|
|
send("\t")
|
|
|
|
sleep(0.1)
|
|
|
|
send("!")
|
|
|
|
expect_str("monster energy=!") # no space
|
|
|
|
send("\b" * 64)
|
|
|
|
|
2020-06-08 15:32:56 +00:00
|
|
|
sendline(
|
|
|
|
"""
|
2020-10-30 18:29:46 +00:00
|
|
|
# Make sure this function does nothing
|
|
|
|
function my_is; :; end
|
2024-01-22 06:42:45 +00:00
|
|
|
complete -c my_is -n 'test (count (commandline -xpc)) = 1' -xa arg
|
2019-11-01 12:21:49 +00:00
|
|
|
complete -c my_is -n '__fish_seen_subcommand_from not' -xa '(
|
2024-01-22 06:42:45 +00:00
|
|
|
set -l cmd (commandline -xpc) (commandline -ct)
|
2019-11-01 12:21:49 +00:00
|
|
|
set cmd (string join " " my_is $cmd[3..-1])" "
|
|
|
|
commandline --replace --current-process $cmd
|
|
|
|
complete -C"$cmd"
|
|
|
|
)'
|
2020-06-08 15:32:56 +00:00
|
|
|
"""
|
|
|
|
)
|
2020-06-08 15:16:09 +00:00
|
|
|
|
|
|
|
send("my_is not \t")
|
|
|
|
send("still.alive")
|
|
|
|
expect_re(".*still.alive")
|
2020-10-30 18:29:46 +00:00
|
|
|
sendline("")
|
|
|
|
|
|
|
|
# Check cancelling completion acceptance
|
|
|
|
# (bind cancel to something else so we don't have to mess with the escape delay)
|
|
|
|
sendline("bind \cg cancel")
|
|
|
|
sendline("complete -c echo -x -a 'foooo bar'")
|
|
|
|
send("echo fo\t")
|
|
|
|
send("\x07")
|
|
|
|
sendline("bar")
|
|
|
|
expect_re("bar")
|
|
|
|
sendline("echo fo\t")
|
|
|
|
expect_re("foooo")
|
|
|
|
|
|
|
|
# As soon as something after the "complete" happened,
|
|
|
|
# cancel should not undo.
|
|
|
|
# In this case that's the space after the tab!
|
|
|
|
send("echo fo\t ")
|
|
|
|
send("\x07")
|
|
|
|
sendline("bar")
|
|
|
|
expect_re("foooo bar")
|
2021-02-24 20:00:56 +00:00
|
|
|
|
|
|
|
sendline("bind \cg 'commandline -f cancel; commandline \"\"'")
|
|
|
|
send("echo fo\t")
|
|
|
|
expect_re("foooo")
|
|
|
|
send("\x07")
|
|
|
|
sendline("echo bar")
|
|
|
|
expect_re("\nbar")
|
|
|
|
sendline("echo fo\t")
|
|
|
|
expect_re("foooo")
|