Closed SebSept closed 7 years ago
I'm guessing it's a case of adding another asterisk in this line...? https://github.com/stecman/symfony-console-completion/blob/master/src/CompletionHandler.php#L420
That was my first try. But no. This function is usless (in that case at least). Filtering is made by zsh autocompletion. replacing with
protected function filterResults(array $array)
{
return ['tic','tac','flac'];
}
then you can see that results are filtered at terminal/console level, not in the php.
The change should be here I suppose : https://github.com/stecman/symfony-console-completion/blob/master/src/HookFactory.php#L70 Zsh completion doc is long to read and require basic shell programming skills (I don't have) :/
I just had a fiddle with that filterResults
function and (at least with default ZSH settings) it looks like it would require config in the shell profile or hook to do anything except the default match from left. Have you used this kind of completion behaviour with other programs under ZSH, @SebSept?
A partial solution might be to remove or optionally disable CompletionHandler::filterResults
and have the shell/hooks handle filtering. This way the result matching behaviour would be up to the user, rather than forced as match from left.
Thanks for fast support (and sorry for long delay to answer).
That's exactly what I did, bypass filterResults
then let zsh do the filtering. I had tried different configuration but nothing is really good as expected (some expected results are not shown).
I had a look in the code of some of "oh my zsh" plugins. Some works perfectly without reconfiguring zsh autocompletion. I've seen there is some ztyle
commands that handle autocompletion as I expect. ( wd plugin as example).
So I think a simple efficient way will be to provide the appropriate zstyle command in the sourced script (_autocompletion command result). I did some tests with zstyle but I'm must admin, it's fuzzy for me :/
Native commands autocomplete as I expect, some zsh plugins also. wd plugin.
cd /tmp
mkdir tests
cd tests
mkdir blabla_stuf && mkdir tic_stuf && mkdir blabla_tic
cd stuf[TAB]
then proposals are blabla_stuf/ tic_stuf/
works same ways with wd plugin
Sorry to leave this one hanging. I'm not a daily ZSH user, so I asked about this query on the ZSH freenode IRC channel a month or two ago:
stecman Hey all, I maintain a library that supports completion under ZSH, but I don't use ZSH much myself. Someone is asking about completions from the middle of words expanding to multiple options (ie. not matching from the start of a word left to right) stecman
https://github.com/stecman/symfony-console-completion/issues/51
stecman Is that a normal kind of thing to do? It looks like it's possible using zstyle, but I'm not familiar enough with it to say Mikachu that's a user configuration thing, not something you should set in your completer Mikachuzstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' +'l:|=* r:|=*'
Mikachu the last element does that Mikachu although he wants Mikachuzstyle ':completion:*' matcher-list 'l:|=* r:|=*'
Mikachu with the+
it'll only do it if there are no prefix-matches at all Mikachu (the case insensitive thing is orthogonal, but configured in the same style)
I suspected this might be a user configuration issue, and it seems that way based on what Mikachu said. If you want to figure out the zstyle part of this, @SebSept, the output of CompletionHandler::filterResults
can probably be tweaked to at least have an option of dumping all completion values instead of filtering internally before returning them to the hook.
Thanks for the support :)
That's ok, I'll deal with zsh config and, yes, change |CompletionHandler::filterResults results.
Maybe proposed behavior (where all results returned to shell, rather than pre-filtered ones) should not be enabled by default.
Closing this for now. If anyone knows the user config necessary to achieve this, feel free to add it to this thread for future reference :cake:
Hi,
Thanks for that lib, I use it and like it :)
I'd like autocompletion for words in the middle, as an example :
display
I'd like to have :
How can we achieve this ?