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

Disable completions when line contains a comment #773

Open
bretello opened this issue Dec 20, 2023 · 1 comment
Open

Disable completions when line contains a comment #773

bretello opened this issue Dec 20, 2023 · 1 comment

Comments

@bretello
Copy link

Problem

When using ZSH_AUTOSUGGEST_STRATEGY=(completion), starting a comment inline sometime results in extra completions being shown after the start of the comment (# )

In the following example, -e is proposed as autosuggestion after the comment (completion for cat)

image

Solution

A potential approach could be disabling completions whenever a comment is started. I've experimented with the following:

export ZSH_AUTOSUGGEST_COMPLETION_IGNORE='* \#*'

which works in basic scenarios, but I'm sure it would break down in some cases (e.g. a string containing <space>#, multi-line statements?)

@pwnalone
Copy link

I'm currently using @bretello's workaround to disable auto-suggestions within comments, but it's not ideal. My zshrc contains the following lines.

ZSH_AUTOSUGGEST_STRATEGY=(history completion)
ZSH_AUTOSUGGEST_COMPLETION_IGNORE='*\#*'
ZSH_AUTOSUGGEST_HISTORY_IGNORE='*\#*'

But now, if there is a # character in the command line that does not begin a comment, then I will no longer get suggestions.

image
image

Maybe this could be solved for # characters contained within strings using a sufficiently fancy glob pattern, but there are other cases too (e.g. arr=(1 2 3); echo "${#arr[@]}" && ...), so I think another solution might be necessary.

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

2 participants