]> granicus.if.org Git - clang/commitdiff
[Bash-completion] Fixed a bug that file doesn't autocompleted after =
authorYuka Takahashi <yukatkh@gmail.com>
Wed, 26 Jul 2017 13:30:36 +0000 (13:30 +0000)
committerYuka Takahashi <yukatkh@gmail.com>
Wed, 26 Jul 2017 13:30:36 +0000 (13:30 +0000)
Summary:
File path wasn't autocompleted after `-fmodule-cache-path=[tab]`, so
fixed this bug by checking if $flags contains only a newline or not.

Differential Revision: https://reviews.llvm.org/D35763

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309112 91177308-0d34-0410-b5e6-96231b3b80d8

utils/bash-autocomplete.sh

index 72531b99e3da539bf3ea11e56094fc83dc3f144d..83c168bf764846b0891e3234451b475911a919bc 100644 (file)
@@ -65,10 +65,14 @@ _clang()
     return
   fi
 
-  if [[ "$cur" == '=' ]]; then
-    COMPREPLY=( $( compgen -W "$flags" -- "") )
-  elif [[ "$flags" == "" || "$arg" == "" ]]; then
+  # When clang does not emit any possible autocompletion, or user pushed tab after " ",
+  # just autocomplete files.
+  if [[ "$flags" == "$(echo -e '\n')" || "$arg" == "" ]]; then
+    # If -foo=<tab> and there was no possible values, autocomplete files.
+    [[ "$cur" == '=' || "$cur" == -*= ]] && cur=""
     _clang_filedir
+  elif [[ "$cur" == '=' ]]; then
+    COMPREPLY=( $( compgen -W "$flags" -- "") )
   else
     # Bash automatically appends a space after '=' by default.
     # Disable it so that it works nicely for options in the form of -foo=bar.