# this script is a part of blesh (https://github.com/akinomyoga/ble.sh) under BSD-3-Clause license ble-import lib/core-complete ble-import lib/core-test ble/test/start-section 'ble/complete' 7 ( function _collect { local text=${args[1]} p0=0 i out= for ((i=0;i<${#ret[@]};i++)); do ((p=ret[i])) if ((i%2==0)); then out=$out${text:p0:p-p0}'[' else out=$out${text:p0:p-p0}']' fi p0=$p done ((p0<${#text})) && out=$out${text:p0} ret=$out } ble/test 'args=(akf Makefile 0); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='M[ak]e[f]ile' ble/test 'args=(akf Makefile 1); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='Makefile' ble/test 'args=(Mkf Makefile 1); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='[M]a[k]e[f]ile' ble/test 'args=(Maf Makefile 1); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='[Ma]ke[f]ile' ble/test 'args=(Mak Makefile 1); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='[Mak]efile' ble/test 'args=(ake Makefile 0); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='M[ake]file' ble/test 'args=(afe Makefile 0); ble/complete/candidates/filter:hsubseq/match "${args[@]}"; _collect' ret='M[a]ke[f]il[e]' ) ble/test/end-section