Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] _git: Complete options and values for -c.



Daniel Shahaf wrote on Fri, Nov 11, 2016 at 09:59:14 +0000:
> This bifurcates _git-config() in order to provide completion for
> 
>     % git -c <TAB>
>     % git -c foo=<TAB>

Interdiff after feedback by Oliver:

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 8e4b6e6..d5a3cfd 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -7527,9 +7527,14 @@ _git() {
         ;;
       (configuration)
         if compset -P 1 '*='; then
-          __git_config_value
+          __git_config_value && ret=0
         else
-          __git_config_option -S =
+          if compset -S '=*'; then
+            __git_config_option
+            compstate[to_end]='' && ret=0 # don't move cursor if we completed just the "foo." in "foo.bar.baz=value"
+          else
+            __git_config_option -S '=' && ret=0
+          fi
         fi
         ;;
     esac

Known issue: completing «git -c user.em<CURSOR>=foo» inserts "ail."
(properly) but puts cursor to the right of the dot, rather than to its
left.



Messages sorted by: Reverse Date, Date, Thread, Author