Correctly handle trailing escaped spaces when completing

Fixes #2447
This commit is contained in:
ridiculousfish
2016-07-11 14:03:19 -07:00
parent fb3c839a15
commit f08ac969e9
2 changed files with 21 additions and 12 deletions

View File

@@ -1818,6 +1818,7 @@ static void test_complete(void) {
if (system("mkdir -p '/tmp/complete_test/'")) err(L"mkdir failed");
if (system("touch '/tmp/complete_test/testfile'")) err(L"touch failed");
if (system("touch '/tmp/complete_test/has space'")) err(L"touch failed");
if (system("chmod 700 '/tmp/complete_test/testfile'")) err(L"chmod failed");
completions.clear();
@@ -1837,6 +1838,14 @@ static void test_complete(void) {
do_test(completions.size() == 1);
do_test(completions.at(0).completion == L"e");
// Completing after spaces - see #2447
completions.clear();
complete(L"echo (ls /tmp/complete_test/has\\ ", &completions, COMPLETION_REQUEST_DEFAULT,
vars);
do_test(completions.size() == 1);
do_test(completions.at(0).completion == L"space");
// Add a function and test completing it in various ways.
struct function_data_t func_data = {};
func_data.name = L"scuttlebutt";