av6 created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers.
REVISION SUMMARY When ->string form is used for _arguments, the function that calls it must declare appropriate local parameters. Managing local return value is needed to tell the completion system if our function succeeded in suggesting something or not, plus without that `hg diff -<TAB>` doesn't look right. While at it, fix a copypaste error (s/diff_files/revert_files/). Docs: http://zsh.sourceforge.net/Doc/Release/Completion-System.html REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D4264 AFFECTED FILES contrib/zsh_completion CHANGE DETAILS diff --git a/contrib/zsh_completion b/contrib/zsh_completion --- a/contrib/zsh_completion +++ b/contrib/zsh_completion @@ -581,7 +581,9 @@ } _hg_cmd_diff() { + local context state state_descr line ret=1 typeset -A opt_args + _arguments -s -S : $_hg_global_opts $_hg_diff_opts $_hg_ignore_space_opts \ $_hg_pat_opts $_hg_subrepos_opts \ '*'{-r+,--rev=}'[revision]:revision:_hg_revrange' \ @@ -591,17 +593,19 @@ '--reverse[produce a diff that undoes the changes]' \ '(--unified -U)'{-U+,--unified=}'[number of lines of context to show]:' \ '--stat[output diffstat-style summary of changes]' \ - '*:file:->diff_files' + '*:file:->diff_files' && ret=0 if [[ $state == 'diff_files' ]] then if [[ -n $opt_args[-r] ]] then - _hg_files + _hg_files && ret=0 else - _hg_committable + _hg_committable && ret=0 fi fi + + return ret } _hg_cmd_export() { @@ -796,46 +800,50 @@ } _hg_cmd_resolve() { - local context state line + local context state state_descr line ret=1 typeset -A opt_args _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \ '(--all -a)'{-a,--all}'[select all unresolved files]' \ '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \ '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \ '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \ '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as resolved]:*:resolved files:_hg_resolved' \ - '*:file:_hg_unresolved' + '*:file:_hg_unresolved' && ret=0 if [[ $state == 'resolve_files' ]] then _alternative 'files:resolved files:_hg_resolved' \ - 'files:unresolved files:_hg_unresolved' + 'files:unresolved files:_hg_unresolved' && ret=0 fi + + return ret } _hg_cmd_revert() { - local context state line + local context state state_descr line ret=1 typeset -A opt_args _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \ '(--rev -r)'{-r+,--rev=}'[revision to revert to]:revision:_hg_labels' \ '(--no-backup -C)'{-C,--no-backup}'[do not save backup copies of files]' \ '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:date code:' \ - '*:file:->diff_files' + '*:file:->revert_files' && ret=0 - if [[ $state == 'diff_files' ]] + if [[ $state == 'revert_files' ]] then if [[ -n $opt_args[-r] ]] then - _hg_files + _hg_files && ret=0 else typeset -a status_files _hg_status mard - _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files + _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files && ret=0 fi fi + + return ret } _hg_cmd_rollback() { To: av6, #hg-reviewers Cc: mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel