mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-16 15:21:14 -03:00
Make completion request flags an enum_set
This commit is contained in:
@@ -2493,7 +2493,7 @@ static void test_complete() {
|
||||
test_complete_vars_t vars;
|
||||
|
||||
completion_list_t completions;
|
||||
complete(L"$", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"$", &completions, {}, vars);
|
||||
completions_sort_and_prioritize(&completions);
|
||||
do_test(completions.size() == 6);
|
||||
do_test(completions.at(0).completion == L"Bar1");
|
||||
@@ -2504,7 +2504,7 @@ static void test_complete() {
|
||||
do_test(completions.at(5).completion == L"Foo3");
|
||||
|
||||
completions.clear();
|
||||
complete(L"$F", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"$F", &completions, {}, vars);
|
||||
completions_sort_and_prioritize(&completions);
|
||||
do_test(completions.size() == 3);
|
||||
do_test(completions.at(0).completion == L"oo1");
|
||||
@@ -2512,13 +2512,12 @@ static void test_complete() {
|
||||
do_test(completions.at(2).completion == L"oo3");
|
||||
|
||||
completions.clear();
|
||||
complete(L"$1", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"$1", &completions, {}, vars);
|
||||
completions_sort_and_prioritize(&completions);
|
||||
do_test(completions.empty());
|
||||
|
||||
completions.clear();
|
||||
complete(L"$1", &completions, COMPLETION_REQUEST_DEFAULT | COMPLETION_REQUEST_FUZZY_MATCH,
|
||||
vars);
|
||||
complete(L"$1", &completions, completion_request_t::fuzzy_match, vars);
|
||||
completions_sort_and_prioritize(&completions);
|
||||
do_test(completions.size() == 2);
|
||||
do_test(completions.at(0).completion == L"$Bar1");
|
||||
@@ -2530,25 +2529,23 @@ static void test_complete() {
|
||||
if (system("chmod 700 'test/complete_test/testfile'")) err(L"chmod failed");
|
||||
|
||||
completions.clear();
|
||||
complete(L"echo (test/complete_test/testfil", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo (test/complete_test/testfil", &completions, {}, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"e");
|
||||
|
||||
completions.clear();
|
||||
complete(L"echo (ls test/complete_test/testfil", &completions, COMPLETION_REQUEST_DEFAULT,
|
||||
vars);
|
||||
complete(L"echo (ls test/complete_test/testfil", &completions, {}, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"e");
|
||||
|
||||
completions.clear();
|
||||
complete(L"echo (command ls test/complete_test/testfil", &completions,
|
||||
COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo (command ls test/complete_test/testfil", &completions, {}, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"e");
|
||||
|
||||
// Completing after spaces - see #2447
|
||||
completions.clear();
|
||||
complete(L"echo (ls test/complete_test/has\\ ", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo (ls test/complete_test/has\\ ", &completions, {}, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"space");
|
||||
|
||||
@@ -2561,23 +2558,23 @@ static void test_complete() {
|
||||
|
||||
// Complete a function name.
|
||||
completions.clear();
|
||||
complete(L"echo (scuttlebut", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo (scuttlebut", &completions, {}, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"t");
|
||||
|
||||
// But not with the command prefix.
|
||||
completions.clear();
|
||||
complete(L"echo (command scuttlebut", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo (command scuttlebut", &completions, {}, vars);
|
||||
do_test(completions.size() == 0);
|
||||
|
||||
// Not with the builtin prefix.
|
||||
completions.clear();
|
||||
complete(L"echo (builtin scuttlebut", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo (builtin scuttlebut", &completions, {}, vars);
|
||||
do_test(completions.size() == 0);
|
||||
|
||||
// Not after a redirection.
|
||||
completions.clear();
|
||||
complete(L"echo hi > scuttlebut", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo hi > scuttlebut", &completions, {}, vars);
|
||||
do_test(completions.size() == 0);
|
||||
|
||||
// Trailing spaces (#1261).
|
||||
@@ -2586,81 +2583,81 @@ static void test_complete() {
|
||||
complete_add(L"foobarbaz", false, wcstring(), option_type_args_only, no_files, NULL, L"qux",
|
||||
NULL, COMPLETE_AUTO_SPACE);
|
||||
completions.clear();
|
||||
complete(L"foobarbaz ", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"foobarbaz ", &completions, {}, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"qux");
|
||||
|
||||
// Don't complete variable names in single quotes (#1023).
|
||||
completions.clear();
|
||||
complete(L"echo '$Foo", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo '$Foo", &completions, {}, vars);
|
||||
do_test(completions.empty());
|
||||
completions.clear();
|
||||
complete(L"echo \\$Foo", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo \\$Foo", &completions, {}, vars);
|
||||
do_test(completions.empty());
|
||||
|
||||
// File completions.
|
||||
completions.clear();
|
||||
complete(L"cat test/complete_test/te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"cat test/complete_test/te", &completions, {}, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"stfile");
|
||||
completions.clear();
|
||||
complete(L"echo sup > test/complete_test/te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo sup > test/complete_test/te", &completions, {}, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"stfile");
|
||||
completions.clear();
|
||||
complete(L"echo sup > test/complete_test/te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"echo sup > test/complete_test/te", &completions, {}, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"stfile");
|
||||
|
||||
if (!pushd("test/complete_test")) return;
|
||||
complete(L"cat te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"cat te", &completions, {}, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"stfile");
|
||||
do_test(!(completions.at(0).flags & COMPLETE_REPLACES_TOKEN));
|
||||
do_test(!(completions.at(0).flags & COMPLETE_DUPLICATES_ARGUMENT));
|
||||
completions.clear();
|
||||
complete(L"cat testfile te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"cat testfile te", &completions, {}, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"stfile");
|
||||
do_test(completions.at(0).flags & COMPLETE_DUPLICATES_ARGUMENT);
|
||||
completions.clear();
|
||||
complete(L"cat testfile TE", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"cat testfile TE", &completions, {}, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"testfile");
|
||||
do_test(completions.at(0).flags & COMPLETE_REPLACES_TOKEN);
|
||||
do_test(completions.at(0).flags & COMPLETE_DUPLICATES_ARGUMENT);
|
||||
completions.clear();
|
||||
complete(L"something --abc=te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"something --abc=te", &completions, {}, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"stfile");
|
||||
completions.clear();
|
||||
complete(L"something -abc=te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"something -abc=te", &completions, {}, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"stfile");
|
||||
completions.clear();
|
||||
complete(L"something abc=te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"something abc=te", &completions, {}, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"stfile");
|
||||
completions.clear();
|
||||
complete(L"something abc=stfile", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"something abc=stfile", &completions, {}, vars);
|
||||
do_test(completions.size() == 0);
|
||||
completions.clear();
|
||||
complete(L"something abc=stfile", &completions, COMPLETION_REQUEST_FUZZY_MATCH, vars);
|
||||
complete(L"something abc=stfile", &completions, completion_request_t::fuzzy_match, vars);
|
||||
do_test(completions.size() == 1);
|
||||
do_test(completions.at(0).completion == L"abc=testfile");
|
||||
|
||||
// Zero escapes can cause problems. See issue #1631.
|
||||
completions.clear();
|
||||
complete(L"cat foo\\0", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"cat foo\\0", &completions, {}, vars);
|
||||
do_test(completions.empty());
|
||||
completions.clear();
|
||||
complete(L"cat foo\\0bar", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"cat foo\\0bar", &completions, {}, vars);
|
||||
do_test(completions.empty());
|
||||
completions.clear();
|
||||
complete(L"cat \\0", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"cat \\0", &completions, {}, vars);
|
||||
do_test(completions.empty());
|
||||
completions.clear();
|
||||
complete(L"cat te\\0", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(L"cat te\\0", &completions, {}, vars);
|
||||
do_test(completions.empty());
|
||||
|
||||
popd();
|
||||
@@ -2672,7 +2669,7 @@ static void test_complete() {
|
||||
fd.name = L"testabbrsonetwothreefour";
|
||||
function_add(fd, parser_t::principal_parser());
|
||||
int ret = pvars.set_one(L"_fish_abbr_testabbrsonetwothreezero", ENV_LOCAL, L"expansion");
|
||||
complete(L"testabbrsonetwothree", &completions, COMPLETION_REQUEST_DEFAULT, pvars);
|
||||
complete(L"testabbrsonetwothree", &completions, {}, pvars);
|
||||
do_test(ret == 0);
|
||||
do_test(completions.size() == 2);
|
||||
do_test(completions.at(0).completion == L"four");
|
||||
@@ -2752,7 +2749,7 @@ static void test_completion_insertions() {
|
||||
static void perform_one_autosuggestion_cd_test(const wcstring &command, const wcstring &expected,
|
||||
const environment_t &vars, long line) {
|
||||
std::vector<completion_t> comps;
|
||||
complete(command, &comps, COMPLETION_REQUEST_AUTOSUGGESTION, vars);
|
||||
complete(command, &comps, completion_request_t::autosuggestion, vars);
|
||||
|
||||
bool expects_error = (expected == L"<error>");
|
||||
|
||||
@@ -2788,7 +2785,7 @@ static void perform_one_autosuggestion_cd_test(const wcstring &command, const wc
|
||||
static void perform_one_completion_cd_test(const wcstring &command, const wcstring &expected,
|
||||
const environment_t &vars, long line) {
|
||||
std::vector<completion_t> comps;
|
||||
complete(command, &comps, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
complete(command, &comps, {}, vars);
|
||||
|
||||
bool expects_error = (expected == L"<error>");
|
||||
|
||||
@@ -2928,7 +2925,7 @@ static void test_autosuggest_suggest_special() {
|
||||
|
||||
static void perform_one_autosuggestion_should_ignore_test(const wcstring &command, long line) {
|
||||
completion_list_t comps;
|
||||
complete(command, &comps, COMPLETION_REQUEST_AUTOSUGGESTION, null_environment_t{});
|
||||
complete(command, &comps, completion_request_t::autosuggestion, null_environment_t{});
|
||||
do_test(comps.empty());
|
||||
if (!comps.empty()) {
|
||||
const wcstring &suggestion = comps.front().completion;
|
||||
|
||||
Reference in New Issue
Block a user