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

Breakage after typing a [ #247

Closed
ivan opened this issue May 21, 2017 · 6 comments
Closed

Breakage after typing a [ #247

ivan opened this issue May 21, 2017 · 6 comments

Comments

@ivan
Copy link

ivan commented May 21, 2017

This happens with 0.4.0, but not 0.3.3:

at@ra:/home/at# while [       
at@ra:/home/at# cd bin                    
at@ra:/home/at/bin:master# while [       
_zsh_autosuggest_strategy_match_prev_cmd:17: bad math expression: operator expected at `bin'
at@ra:/home/at/bin:master# while [
at@ra:/home/at/bin:master# while [       
_zsh_autosuggest_strategy_match_prev_cmd:17: bad math expression: operator expected at `bin'
at@ra:/home/at/bin:master# while [
at@ra:/home/at/bin:master# [
_zsh_autosuggest_strategy_match_prev_cmd:17: bad math expression: operator expected at `bin'
at@ra:/home/at/bin:master# [
at@ra:/home/at/bin:master# [
_zsh_autosuggest_strategy_match_prev_cmd:17: bad math expression: operator expected at `bin'
at@ra:/home/at/bin:master# [
at@ra:/home/at/bin:master# [
_zsh_autosuggest_strategy_match_prev_cmd:17: bad math expression: operator expected at `bin'
at@ra:/home/at/bin:master# [
at@ra:/home/at/bin:master# ]]]][
_zsh_autosuggest_strategy_match_prev_cmd:17: bad math expression: operator expected at `bin'

The _zsh_autosuggest_strategy_match_prev_cmd error pops up immediately after pressing the [ key.

# zsh --version                                               
zsh 5.1.1 (x86_64-ubuntu-linux-gnu)

.zshrc settings: https://gist.github.com/ivan/79de5e87210e8cf21e305bb4c30c4360#file-zshrc-L200-L206 possibly-relevant bit being

ZSH_AUTOSUGGEST_STRATEGY=match_prev_cmd
@ericfreese
Copy link
Member

Looks like this is specific to match_prev_cmd strategy.

@Birne94
Copy link

Birne94 commented Jun 20, 2017

I am receiving a similar error with the latest release (master @ 2cb6eb6 - (tag: v0.4.0)) when pressing the number sign (#):

daniel@Daniels-MBP ~/Workspace/dotfiles % #
_zsh_autosuggest_strategy_match_prev_cmd:17: bad math expression: operator expected at `ZSH_AUTOSU...'
daniel@Daniels-MBP ~/Workspace/dotfiles % #

@paulbdavis
Copy link

paulbdavis commented Jul 13, 2017

I am having the same thing happen as @Birne94 except only on my remote machine. I have the same config in my local setup (both have the plugin up to date with master) and it can type # just fine

It does not have a problem typing a [ character

@arizonahanson
Copy link
Contributor

arizonahanson commented Aug 10, 2017

I "fixed" this by changing the _zsh_autosuggest_strategy_match_prev_cmd() to escape the match key (and then rebuilding the main file with make).

--- a/src/strategies/match_prev_cmd.zsh
+++ b/src/strategies/match_prev_cmd.zsh
@@ -26,7 +26,7 @@ _zsh_autosuggest_strategy_match_prev_cmd() {
        # Get all history event numbers that correspond to history
        # entries that match pattern $prefix*
        local history_match_keys
-   history_match_keys=(${(k)history[(R)$prefix*]})
+  history_match_keys=(${(k)history[(R)${(b)prefix}*]})
 
        # By default we use the first history number (most recent history entry)
        local histkey="${history_match_keys[1]}"

not entirely sure if this is the best solution

@arizonahanson
Copy link
Contributor

arizonahanson commented Aug 18, 2017

made a pull request: #267

ssiegel added a commit to ssiegel/zsh-autosuggestions that referenced this issue Sep 10, 2017
Maybe this is also a fix for zsh-users#247, zsh-users#248 and zsh-users#258. Supersedes zsh-users#267.

Testcase:
Using match_prev_cmd strategy and with these lines in history:
echo '1^'
echo '2^'
echo '1^'

type:
echo       (unexpected suggestion echo '1^' instead of echo '2^')
echo '1^1  (wrong suggestion echo '1^1echo '1^')
echo '1^#  (error "bad math expression")
@ericfreese
Copy link
Member

Should be fixed now on develop.

ericfreese added a commit that referenced this issue Dec 6, 2017
To support older versions of zsh (< 5.0.8).

We were missing the EXTENDED_GLOB option that allows use of `(#m)` flag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants