37 lines
1.5 KiB
Plaintext
37 lines
1.5 KiB
Plaintext
_zimfw_check_dumpfile() {
|
|
local zdumpfile
|
|
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=<%= home %>/.zcompdump
|
|
if [[ -e ${zdumpfile} ]]; then
|
|
local -i zup_to_date=-1
|
|
local zline
|
|
IFS=$' \t' read -rA zline < ${zdumpfile} || return 1
|
|
if [[ ${zline[4]} != ${ZSH_VERSION} ]] zup_to_date=0
|
|
if (( zup_to_date != 0 && ${+_zim_fpath} )); then
|
|
local -r zold_zim_comps=(${^_zim_fpath}/^([^_]*|*~|*.zwc(|.old))(N:t))
|
|
local -r zpre=$'*\0'
|
|
local -r znew_zim_fpath=(${${_zfpaths#${~zpre}}:A})
|
|
local -r znew_zim_comps=(${^znew_zim_fpath}/^([^_]*|*~|*.zwc(|.old))(N:t))
|
|
if (( ${#zold_zim_comps} != ${#znew_zim_comps} )) zup_to_date=0
|
|
fi
|
|
if (( zup_to_date != 0 && ${+_zim_dumpfile_fpath} )); then
|
|
local -r znew_dumpfile_comps=(${^_zim_dumpfile_fpath}/^([^_]*|*~|*.zwc(|.old))(N:t))
|
|
if (( ${zline[2]} == ${#znew_dumpfile_comps} )); then
|
|
zup_to_date=1
|
|
else
|
|
zup_to_date=0
|
|
fi
|
|
fi
|
|
case ${zup_to_date} in
|
|
-1) _zimfw_print -u2 -PR "%F{yellow}<%= warn %>%B${zdumpfile}:%b Unable to check. Initialize the completion module first." ;;
|
|
1) _zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b Already up to date" ;;
|
|
0)
|
|
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b New completion configuration needs to be dumped. Will do %Bclean-dumpfile%b."
|
|
_zimfw_clean_dumpfile
|
|
;;
|
|
esac
|
|
else
|
|
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b Not found"
|
|
fi
|
|
_zimfw_print 'Done with check-dumpfile.'
|
|
}
|