Skip to content

Commit 22562aa

Browse files
committed
WIP: Snapshot that *almost* passes tests, but may or may not be correct.
Current test failures: Running test main # parameter-value-contains-command-position1 1..2 ok 1 - [1,7] «$foobar» not ok 2 - have 1 expectations and 2 region_highlight entries: «expected_region_highlight=( '1 7 assign' )» «region_highlight=( '0 7 assign' '0 7 assign' )» # parameter-value-contains-command-position2 1..2 ok 1 - [1,2] «$y» not ok 2 - have 1 expectations and 2 region_highlight entries: «expected_region_highlight=( '1 2 assign' )» «region_highlight=( '0 2 assign' '0 2 assign' )»
1 parent 3dca9d5 commit 22562aa

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

highlighters/main/main-highlighter.zsh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,13 @@ _zsh_highlight_main_add_region_highlight() {
7878
return
7979
fi
8080
if (( in_param )); then
81-
[[ $1 == unknown-token ]] && param_style=unknown-token
82-
return
81+
if [[ $1 == unknown-token ]]; then
82+
param_style=unknown-token
83+
fi
84+
if [[ -n $param_style ]]; then
85+
return
86+
fi
87+
param_style=$1
8388
fi
8489

8590
# The calculation was relative to $buf but region_highlight is relative to $BUFFER.
@@ -955,8 +960,9 @@ _zsh_highlight_main_highlighter_highlight_list()
955960
fi
956961
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
957962
done
963+
: ${param_style:=$style}
958964
(( in_alias == 1 )) && in_alias=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style
959-
(( in_param == 1 )) && in_param=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos ${param_style:-unknown_token}
965+
(( in_param == 1 )) && in_param=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $param_style
960966
[[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\$'\n')#) ]]
961967
REPLY=$(( end_pos + ${#match[1]} - 1 ))
962968
reply=($list_highlights)

0 commit comments

Comments
 (0)