keith / zsh-xcode-completions

Zsh completion for the Xcode command line tools
MIT License
57 stars 5 forks source link

Possible bug caused by using " " as message on argument completion (*) #2

Closed kastiglione closed 1 year ago

kastiglione commented 8 years ago

In this project, the _arguments function is generally given an argument completion in the form of:

*: :->action

Why is the message a single space?

Currently, when I do xcodebuild -<TAB>, I get 162 lines of output. The output consists of all options, plus their descriptions being listed on their own line with a -- prefix, plus a bunch of blank lines, and all of this gets repeated three times.

When I changed this line of _xcodebuild to:

*::->actions

the use of an empty message, instead of one space, caused the tab completion of - options to work as expected.

I'm using zsh version 5.0.5.

keith commented 8 years ago

I can look into that, maybe the commit messages as well. I don't remember exactly but I believe that was required for something...

kastiglione commented 8 years ago

The closest thing that appears to be related, but not quite the same is: 0ae37347c55c96b83bc820a6766200547450ff60. It seems all files have had a single space message from the start.

keith commented 8 years ago

Interesting, as long as all the mentioned combinations worked it should be fine. I remember at some point there being an issue with the cases of:

1) xcodebuild ACTION -<TAB> 2) xcodebuild -<TAB> AC<TAB> 3) xcodebuild -arg ACTION -<TAB>

As long as those still work without that space then we're good!

kastiglione commented 8 years ago

According to man zshcompsys, there are three forms:

*:message:action
*::message:action
*:::message:action

and so *::->actions is perhaps being interpreted as the second with a message of "->actions".

Which puts me back to the start, getting bad completion for - options.

keith commented 8 years ago

Hmm. I wonder if the original issue you mention here of getting so many lines is caused by that, or a config issue on one of our sides. Here's what I get:

screen shot 2016-02-21 at 11 04 42
kastiglione commented 8 years ago

I'll move my config files aside and try with defaults.

kastiglione commented 8 years ago

This line in my .zshrc is part of the problem:

zstyle ':completion:*' matcher-list '' '+m:{[:lower:]}={[:upper:]}'

This is added by compinstall. I don't do any other customization, it's just this one line, which allows lower-to-upper matching when doing completion. I have no idea why these two things would conflict.

keith commented 8 years ago

Interesting. I don't either. Does the change your suggesting have any negative effects though? Because if it doesn't we could definitely merge it regardless.

kastiglione commented 8 years ago

Yeah, it made autocomplete half broken. I'm hoping to play around with this more over time to figure out a working fix.

keith commented 8 years ago

Let me know what you find!

PatTheMav commented 1 year ago

@keith I did try out your completions for the first time today and ran into similar issues, mainly when providing a single hyphen Zsh provided me with 186 completions, which were made up of:

I dug into the script and found that the correct way to offer completion for the actions as well as correct completion of all arguments even with complex completion setups is to call the _actions function directly and not use a state switch:

_arguments \
[...]
  ':*:Build actions:_actions

I gleaned this from other Zsh completions and at least in my tests it fixed all my issues:

I dunno if the position in the _arguments call is of significance, but I moved it to the bottom of the call for now.

keith commented 1 year ago

def happy to take PRs, I haven't debugged this in a while 😕

PatTheMav commented 1 year ago

def happy to take PRs, I haven't debugged this in a while 😕

Opened https://github.com/keith/zsh-xcode-completions/pull/16 to fix this.

keith commented 1 year ago

Thanks!