zsh-users / zsh-autosuggestions

Fish-like autosuggestions for zsh
MIT License
31.11k stars 1.86k forks source link

Fix 'bad math expression' bug #680

Open bbugyi200 opened 2 years ago

bbugyi200 commented 2 years ago

The problem seems to be that when the POSTDISPLAY envvar is not set, $#POSTDISPLAY sometimes evaluates to 0POSTDISPLAY instead of 0.

Using curly braces (i.e. ${#POSTDISPLAY}) to disambiguate should mitigate this issue. This should also be a low-risk change IMO, although I will admit that I have no idea why I am just now seeing this error message.

Fixes #679

bashenk commented 2 years ago

I've noticed extremely similar behavior, at one time or another, myself. It might be a good idea to consider doing this for each reference of $#POSTDISPLAY where it could theoretically be unset, since it does show up elsewhere (src/widgets.zsh, src/highlight.zsh, and the _zsh_autosuggest_accept function in the same file). If no one gets around to it I can fork and submit a PR at a later date.