fix: argparse based completions should work in newer python versions (#5542)

PS.

e47ecbd042

fixes #5471
This commit is contained in:
Noorhteen Raja NJ 2024-06-27 11:55:39 +05:30 committed by GitHub
parent 12aa885d7b
commit fa254914d7
Failed to generate hash of commit
2 changed files with 25 additions and 1 deletions

View file

@ -56,3 +56,27 @@ def test_skipper_arg(completion_context_parse, xession, monkeypatch):
assert context.command == CommandContext(
args=(CommandArg("grep"),), arg_index=1, prefix="--coun"
)
def test_argparse_completer(check_completer, monkeypatch):
assert check_completer("xonsh", prefix="-").issuperset(
{
"--cache-everything",
"--help",
"--interactive",
"--login",
"--no-env",
"--no-rc",
"--no-script-cache",
"--rc",
"--shell-type",
"--timings",
"--version",
}
)
def test_argparse_completer_after_option(check_completer, tmp_path):
prefix = str(tmp_path)[:-1]
# has one or more completions including the above tmp_path
assert check_completer("xonsh --no-rc", prefix)

View file

@ -545,7 +545,7 @@ class ArgparseCompleter:
break
# it is a valid option and advance
self.remaining_args = self.remaining_args[1:]
act, _, value = act_res
act, *_, value = act_res
# remove the found option
# todo: not remove if append/extend