Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zsh completion issue due to new '[.md' page #166

Closed
cho-m opened this issue Mar 18, 2021 · 5 comments · Fixed by #168
Closed

zsh completion issue due to new '[.md' page #166

cho-m opened this issue Mar 18, 2021 · 5 comments · Fixed by #168

Comments

@cho-m
Copy link

cho-m commented Mar 18, 2021

Currently, ZSH tab-completion is erroring with:

tldr <tab>
_values:compvalues:11: invalid value definition: [

This may be due to TLDR adding a new page for '[.md' recently

Taking a look at ZSH Parameter Expansion, one option seems to be to use the q option:

q

Quote characters that are special to the shell in the resulting words with backslashes; unprintable or invalid characters are quoted using the $’\NNN’ form, with separate quotes for each octet.

If this flag is given twice, the resulting words are quoted in single quotes and if it is given three times, the words are quoted in double quotes; in these forms no special handling of unprintable or invalid characters is attempted. If the flag is given four times, the words are quoted in single quotes preceded by a $. Note that in all three of these forms quoting is done unconditionally, even if this does not change the way the resulting string would be interpreted by the shell.

If a q- is given (only a single q may appear), a minimal form of single quoting is used that only quotes the string if needed to protect special characters. Typically this form gives the most readable output.

If a q+ is given, an extended form of minimal quoting is used that causes unprintable characters to be rendered using $’...’. This quoting is similar to that used by the output of values by the typeset family of commands.

@dbrgn
Copy link
Collaborator

dbrgn commented Mar 18, 2021

Thanks! Since I'm not a zsh user myself: Tested pull requests are welcome!

@cho-m
Copy link
Author

cho-m commented Mar 19, 2021

I'll test it a bit and try some other options.

I do see an issue when dealing with an empty cache since it tab-completes an escaped empty string.

❯ tldr <tab>

❯ tldr \'\'

@cho-m
Copy link
Author

cho-m commented Mar 19, 2021

Created PR using different array solution rather than q option to resolve a few other issues.

dbrgn pushed a commit that referenced this issue Mar 21, 2021
…extra _files args (#168)

- Use array `commands=(...)` and `_describe` to deal with '[.md' & empty cache scenario.  Fixes #166
- Hide `tldr --list` stderr (`2>/dev/null`) which breaks completion with empty cache
- Remove `sed` since #112 changed commas to newlines
- Add new `sed`-equivalent replacement (`:` -> `\:`) using native [ZSH `${name//pattern/repl}`](http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion) since colon is special character in ZSH completions
- Add basic support for `-L, --language` flag from #125. In future, can consider adding extra completions maybe based on caches `pages.{lang}` folders.
- Remove extraneous completion of file names for positional arguments (i.e. `'*:file:_files'`)
@lovetoburnswhen
Copy link

Has this been released yet?

@dbrgn
Copy link
Collaborator

dbrgn commented Jun 18, 2021

@lovetoburnswhen no, not yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants