Skip to content

Commit bc3b943

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 2d0f51b commit bc3b943

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

highlighters/main/main-highlighter.zsh

+9-3
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.
@@ -963,8 +968,9 @@ _zsh_highlight_main_highlighter_highlight_list()
963968
fi
964969
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
965970
done
971+
: ${param_style:=$style}
966972
(( in_alias == 1 )) && in_alias=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style
967-
(( in_param == 1 )) && in_param=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos ${param_style:-"unknown-token"}
973+
(( in_param == 1 )) && in_param=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $param_style
968974
[[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\$'\n')#) ]]
969975
REPLY=$(( end_pos + ${#match[1]} - 1 ))
970976
reply=($list_highlights)

0 commit comments

Comments
 (0)