Re: r309112 - [Bash-completion] Fixed a bug that file doesn't autocompleted after =

2017-07-28 Thread Hans Wennborg via cfe-commits
Merged to 5.0 in r309435.

On Wed, Jul 26, 2017 at 6:30 AM, Yuka Takahashi via cfe-commits
 wrote:
> Author: yamaguchi
> Date: Wed Jul 26 06:30:36 2017
> New Revision: 309112
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309112=rev
> Log:
> [Bash-completion] Fixed a bug that file doesn't autocompleted after =
>
> 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
>
> Modified:
> cfe/trunk/utils/bash-autocomplete.sh
>
> Modified: cfe/trunk/utils/bash-autocomplete.sh
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=309112=309111=309112=diff
> ==
> --- cfe/trunk/utils/bash-autocomplete.sh (original)
> +++ cfe/trunk/utils/bash-autocomplete.sh Wed Jul 26 06:30:36 2017
> @@ -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= 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.
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r309112 - [Bash-completion] Fixed a bug that file doesn't autocompleted after =

2017-07-26 Thread Yuka Takahashi via cfe-commits
Author: yamaguchi
Date: Wed Jul 26 06:30:36 2017
New Revision: 309112

URL: http://llvm.org/viewvc/llvm-project?rev=309112=rev
Log:
[Bash-completion] Fixed a bug that file doesn't autocompleted after =

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

Modified:
cfe/trunk/utils/bash-autocomplete.sh

Modified: cfe/trunk/utils/bash-autocomplete.sh
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=309112=309111=309112=diff
==
--- cfe/trunk/utils/bash-autocomplete.sh (original)
+++ cfe/trunk/utils/bash-autocomplete.sh Wed Jul 26 06:30:36 2017
@@ -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= 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.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits