log_trace("[compseq] Looking at sequence item[$itemidx] : %s", $item) if$COMPLETE_SEQUENCE_TRACE;
my@array= _get_strings_from_item($item, $stash);
log_trace("[compseq] Result from sequence item[$itemidx]: %s", \@array) if$COMPLETE_SEQUENCE_TRACE;
my$res= Complete::Util::complete_array_elem(
word=> $word,
array=> \@array,
);
if($res&& @$res== 1) {
# the word can be completed directly (unambiguously) with this item.
# move on to get more words from the next item.
log_trace("[compseq] Word ($word) can be completed unambiguously with this sequence item[$itemidx], moving on to the next sequence item") if$COMPLETE_SEQUENCE_TRACE;
substr($word, 0, length$res->[0]) = "";
$stash->{cur_word} = $word;
push@prefixes_from_completed_items, $res->[0];
next;
} elsif($res&& @$res> 1) {
# the word can be completed with several choices from this item.
log_trace("[compseq] Word ($word) can be completed with several choices from this sequence item[$itemidx], returning final result: %s", $compres) if$COMPLETE_SEQUENCE_TRACE;
return$compres;
} else{
# the word cannot be completed with this item. it can be that the
log_trace("[compseq] Word ($word) cannot be completed by this sequence item[$itemidx] because part of the word matches previous sequence item(s); completed_parts=%s, word=%s", \@prefixes_from_completed_items, $word) if$COMPLETE_SEQUENCE_TRACE;
next;
}
# nope, this word simply doesn't match
log_trace("[compseq] Word ($word) cannot be completed by this sequence item[$itemidx], giving up the rest of the sequence items") if$COMPLETE_SEQUENCE_TRACE;