From 17f2668d1f757b8399bd1147c666adb3a1c3c056 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 1 Jul 2020 05:33:33 -0700 Subject: [PATCH] When tab-completing "arc" commands, suggest paths if the argument is empty and a path wildcard argument exists Summary: Currently, if you type "arc upload ", we do not autocomplete the working directory. We should, but the "current argument" is the empty string and that's technically a prefix of every flag, so we suggest that you might want a flag instead. You probably don't. Suggest paths in this case. Test Plan: - Ran "arc upload ", saw path completions. - Ran "arc land " (this workflow does NOT take paths as arguments), saw flag completions. Differential Revision: https://secure.phabricator.com/D21385 --- .../workflow/ArcanistShellCompleteWorkflow.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/toolset/workflow/ArcanistShellCompleteWorkflow.php b/src/toolset/workflow/ArcanistShellCompleteWorkflow.php index 4fc1fb0a..f68d04a5 100644 --- a/src/toolset/workflow/ArcanistShellCompleteWorkflow.php +++ b/src/toolset/workflow/ArcanistShellCompleteWorkflow.php @@ -585,12 +585,18 @@ EOTEXT $matches = $this->getMatches($flags, $current); // If whatever the user is completing does not match the prefix of any - // flag, try to autcomplete a wildcard argument if it has some kind of - // meaningful completion. For example, "arc lint READ" should - // autocomplete a file. + // flag (or is entirely empty), try to autcomplete a wildcard argument + // if it has some kind of meaningful completion. For example, "arc lint + // READ" should autocomplete a file, and "arc lint " should + // suggest files in the current directory. - if (!$matches && $wildcard) { + if (!strlen($current) || !$matches) { + $try_paths = true; + } else { + $try_paths = false; + } + if ($try_paths && $wildcard) { // TOOLSETS: There was previously some very questionable support for // autocompleting branches here. This could be moved into Arguments // and Workflows.