aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/fish_tests.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-02-27 16:28:47 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-02-27 16:51:44 -0800
commit6cb48c63800604e40ba759763ab410beceb74b89 (patch)
tree23d1e3076b844b50d4dc7a72a8bf84c807a56aa4 /src/fish_tests.cpp
parent99be3ee96f26b1acfef26085fc9780b6a2ecfe0d (diff)
Allow variable completion from just a $
Previously there had to be some variable text, now you can tab complete from just a naked $.
Diffstat (limited to 'src/fish_tests.cpp')
-rw-r--r--src/fish_tests.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp
index 9be273e6..d6972139 100644
--- a/src/fish_tests.cpp
+++ b/src/fish_tests.cpp
@@ -2106,7 +2106,19 @@ static void test_complete(void)
const env_vars_snapshot_t &vars = env_vars_snapshot_t::current();
std::vector<completion_t> completions;
+ complete(L"$", &completions, COMPLETION_REQUEST_DEFAULT, vars);
+ completions_sort_and_prioritize(&completions);
+ do_test(completions.size() == 6);
+ do_test(completions.at(0).completion == L"Bar1");
+ do_test(completions.at(1).completion == L"Bar2");
+ do_test(completions.at(2).completion == L"Bar3");
+ do_test(completions.at(3).completion == L"Foo1");
+ do_test(completions.at(4).completion == L"Foo2");
+ do_test(completions.at(5).completion == L"Foo3");
+
+ completions.clear();
complete(L"$F", &completions, COMPLETION_REQUEST_DEFAULT, vars);
+ completions_sort_and_prioritize(&completions);
do_test(completions.size() == 3);
do_test(completions.at(0).completion == L"oo1");
do_test(completions.at(1).completion == L"oo2");
@@ -2114,13 +2126,15 @@ static void test_complete(void)
completions.clear();
complete(L"$1", &completions, COMPLETION_REQUEST_DEFAULT, vars);
+ completions_sort_and_prioritize(&completions);
do_test(completions.empty());
completions.clear();
complete(L"$1", &completions, COMPLETION_REQUEST_DEFAULT | COMPLETION_REQUEST_FUZZY_MATCH, vars);
+ completions_sort_and_prioritize(&completions);
do_test(completions.size() == 2);
- do_test(completions.at(0).completion == L"$Foo1");
- do_test(completions.at(1).completion == L"$Bar1");
+ do_test(completions.at(0).completion == L"$Bar1");
+ do_test(completions.at(1).completion == L"$Foo1");
if (system("mkdir -p '/tmp/complete_test/'")) err(L"mkdir failed");
if (system("touch '/tmp/complete_test/testfile'")) err(L"touch failed");