Skip to content

Aliases containing suffix-aliases as the first element are highlighted wrongly as suffix-alias #574

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

Closed
frebib opened this issue Oct 30, 2018 · 6 comments

Comments

@frebib
Copy link

frebib commented Oct 30, 2018

Following the discussion in #565, it seems to be affecting me too. I don't see any mention of suffix-alias but it seems that all aliases are highlighted to whatever I set the suffix-alias highlight to.

It doesn't bother me too much as I've just set suffix-alias to what I had alias set to before, I don't really use global/suffix aliases much.

Running commit 4ce56a8

@danielshahaf
Copy link
Member

Cannot reproduce. Do you set ZSH_HIGHLIGHT_STYLES[suffix-alias]=$ZSH_HIGHLIGHT_STYLES[alias] anywhere? Can you reproduce this in zsh -f?

Aside: To test this I had to set ZSH_HIGHLIGHT_STYLES to empty, otherwise changes to the fg color of alias were ignored since they were overridden by fg=green of the aliased thing — so it's not possible to give alias-to-function a different fg than function. We should highlight the alias word as "alias-function 1 3", not as "alias 1 3" "function 1 3". (Or at least do "function 1 3" "alias 1 3" so the alias can override. Anyway, we can discuss the aside further on a separate issue to not hijack @frebib's thread.)

@frebib
Copy link
Author

frebib commented Oct 30, 2018

https://github.com/frebib/dotfiles/blob/master/.config/zsh/.zshrc#L116-L117

Interestingly I cannot reproduce it with zsh -f either, it seems to behave as it should.
Which other highlighters should affect highlighting aliases? So I can test some more to attempt to find the conflict.

@frebib
Copy link
Author

frebib commented Oct 30, 2018

AH.

I have alias -s git="git clone --recursive" and other aliases such as alias ga="git add" which is causing any alias where git is the first item to be highlighted as a suffix-alias.

Whilst these are somewhat related it is not the expected behaviour. Perhaps a regression?

@frebib frebib changed the title All aliases are always highlighted as suffix-alias Aliases containing suffix-aliases as the first element are highlighted wrongly as suffix-alias Oct 30, 2018
@danielshahaf
Copy link
Member

danielshahaf commented Oct 30, 2018 via email

@frebib
Copy link
Author

frebib commented Oct 30, 2018

zsh -f
source path/to/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
ZSH_HIGHLIGHT_STYLES[alias]='fg=red'
ZSH_HIGHLIGHT_STYLES[suffix-alias]='fg=magenta'
alias ga="git add"
ga # this is highlighted red
alias -s git="git clone"
[email protected]/repo.git  # this is magenta
ga # this is also magenta but should still be red

@danielshahaf
Copy link
Member

I can reproduce this, and you don't even need ga for this. Just alias -s git='git clone and then git at command position is considered a suffix alias. It was a long-standing bug unrelated to the recent changes.

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