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

Case-insensitive completion with partial substring matching



Hi every one,

I was looking for a way to enable case-insensitive completion with partial substring matching, and it seems many people are using this:

zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'

However, people at Oh-My-Zsh found it triggers an interesting "bug" [1]. To be clear, it is not related to OMZ (at least, no further than the fact that OMZ also uses that line). I call it a "bug", but it is just an undesirable side-effect of the matcher-list statement, and I want to understand how to fix it.

How to reproduce?
The "bug" occurs when a completion is triggered with multiple choices such that:
* completion choices are all the same length;
* completion choices share a common suffix;
* that suffix is at least half of the length but not the full length;
* in each choice, the first and the n-th character of the suffix are both letters, where n is the length of the prefix;
* in each choice, the character just before the common suffix is a digit (maybe it works with other character types but i did not find any), and that character is different for each choice.

Under the above conditions, the "bug" occurs when completing after a substring prefixing the common suffix (i.e. completing after "a" or "ab" or "abc", when the common suffix is "abc") will insert a letter before the suffix. This letter will be the n-th character of the suffix, in inverted case.

Example: in a directory containing two files "1abc" and "2abc", completing after "less a" will expand it to "abc" and then add an extra "A", so the command line will look like "less Aabc".

I am still struggling to understand the depth of Zsh's completion system, so please, can anyone help me understand why the above behavior happens? Especially why does it specifically happen with digits?

Just pointing me in the right direction will be greatly appreciated. Best regards.

Nicolas Canceill

[1] https://github.com/robbyrussell/oh-my-zsh/issues/2030



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