'main': Parameter expansions may not contain assignments.

In «a="b=c"; $a», the '=' sign in the expansion of $a is not active.
Therefore, prevent the expansion of $a from being considered an
assignment.  Update test expectations accordingly.

As a side effect, this prevents line 836 from firing for the cases in
these two tests, thereby fixing the double $region_highlight addition
(see log message of the previous commit).  That leaves the line 966
addition.  However, the double addition remains a latent bug (see
discussion in PR #684).
This commit is contained in:
Daniel Shahaf 2020-02-20 11:37:23 +00:00
parent bc3b94349d
commit aa561299f2
3 changed files with 3 additions and 3 deletions

View File

@ -839,7 +839,7 @@ _zsh_highlight_main_highlighter_highlight_list()
function) style=function;; function) style=function;;
command) style=command;; command) style=command;;
hashed) style=hashed-command;; hashed) style=hashed-command;;
none) if _zsh_highlight_main_highlighter_check_assign; then none) if (( ! in_param )) && _zsh_highlight_main_highlighter_check_assign; then
_zsh_highlight_main_add_region_highlight $start_pos $end_pos assign _zsh_highlight_main_add_region_highlight $start_pos $end_pos assign
local i=$(( arg[(i)=] + 1 )) local i=$(( arg[(i)=] + 1 ))
if [[ $arg[i] == '(' ]]; then if [[ $arg[i] == '(' ]]; then

View File

@ -34,5 +34,5 @@ BUFFER=$'$foobar'
expected_region_highlight=( expected_region_highlight=(
# Used to highlight the "ba" as 'command' because the 'ls' showed through; issues #670 and #674 # Used to highlight the "ba" as 'command' because the 'ls' showed through; issues #670 and #674
'1 7 assign' # $foobar '1 7 unknown-token' # $foobar (not an assignment)
) )

View File

@ -34,5 +34,5 @@ BUFFER=$'$y'
expected_region_highlight=( expected_region_highlight=(
# Used to trigger a "BUG" message on stderr - issues #670 and #674 # Used to trigger a "BUG" message on stderr - issues #670 and #674
'1 2 assign' # $y '1 2 unknown-token' # $y (not an assignment)
) )