-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Attempt to fix #670 #682
Attempt to fix #670 #682
Conversation
Don't highlight parameters based on parameter expansion if the expansion type is 'none'.
Correct me if I'm wrong, but if the type is |
Also, the PR fails tests. |
If the type is I've fixed the thing that broke the test -- the subcase of I'm not willing to rewrite the pattern matching code to deal with things like |
Right, diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh
index aa50589..1730b02 100644
--- a/highlighters/main/main-highlighter.zsh
+++ b/highlighters/main/main-highlighter.zsh
@@ -642,13 +642,8 @@ _zsh_highlight_main_highlighter_highlight_list()
;;
esac
_zsh_highlight_main__type "$testarg" 0
- if [[ -n $REPLY ]] && [[ $REPLY != none ]]; then
- res=$REPLY
- arg=$testarg
- elif _zsh_highlight_main_highlighter_check_path $testarg; then
- res=none
- arg=$testarg
- fi
+ res=$REPLY
+ arg=$testarg
fi
}
Tests pass with and without this.
Thanks.
Yes, that's exactly how it's designed.
Supporting
What do you mean, "most" previous functionality? Are there some cases that worked before that don't work now? |
This was what happened before the PR. If
Well, anything else that highlighted when |
Right, so the diff I posted wouldn't be the complete fix.
Sorry, but i think that's wrong. What you're saying is, in terms of the language semantics, like saying that parameter expansion in command position only happens when the expansion of the parameter is itself valid at command position or is a path. That is not how the language works. The distinction between $arg and $testarg, on the other hand, is spot on. We should make a distinction between the word in $BUFFER and the word after parameter and alias expansions. The former should be used for $region_highlight calculations and the latter for parsing.
Yes, that's wrong too. We don't currently observe the order of expansions. However, I don't consider this defect to be a blocker. |
Closed per discussion on #684. (Would have said so earlier but my client indicated the |
Fixed on #684. |
Don't highlight parameters based on parameter expansion if the expansion type is
'none'.
As noted in the code comments, it's useful to highlight a parameter whose value happens to be a reserved word, command, etc. as the value would be highlighted. However, if the type is "none", then there's not enough information to highlight the argument, so just highlight the un-expanded parameter.