Follow-up to 547b8be30461: Fix $observed_result calculation.

In region_highlight, a spec of the form 'i j foo' with i >= j should have no effect.
Before this commit, however, the {$i..$j} range would happily expand to (5 4 3)
if i > j were the case (e.g., i=5 and j=3).

This breaks vanilla-newline.zsh; the next commit will fix that.
This commit is contained in:
Daniel Shahaf 2015-09-17 23:17:22 +00:00
parent 4068413dfe
commit aab1b8f50f
1 changed files with 10 additions and 5 deletions

View File

@ -91,11 +91,16 @@ for data_file in ${0:h:h}/highlighters/$1/test-data/*.zsh; do
for i in {1..${#region_highlight}}; do
highlight_zone=${(z)region_highlight[$i]}
integer start=$highlight_zone[1] end=$highlight_zone[2]
(( --end )) # region_highlight ranges are half-open
(( ++start, ++end )) # region_highlight is 0-indexed; expected_region_highlight is 1-indexed
for j in {$start..$end}; do
observed_result[$j]=$highlight_zone[3]
done
if (( start < end )) # region_highlight ranges are half-open
then
(( --end )) # convert to closed range, like expected_region_highlight
(( ++start, ++end )) # region_highlight is 0-indexed; expected_region_highlight is 1-indexed
for j in {$start..$end}; do
observed_result[$j]=$highlight_zone[3]
done
else
# noop range; ignore.
fi
done
# Then we compare the observed result with the expected one.