More accurate check-dumpfile action

by using the `_zim_dumpfile_fpath` variable set by the completion module
[here](33737e8c15/init.zsh (L11))
right before `compinit` is run.
This commit is contained in:
Eric Nielsen 2023-02-03 18:53:07 -05:00
parent 281cde57f7
commit a434fda508
No known key found for this signature in database
GPG Key ID: 678AF5E338C87D99
4 changed files with 28 additions and 30 deletions

View File

@ -7,7 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
_No unreleased changes._
### Fixed
- Use `_zim_dumpfile_fpath` defined by the completion module
[here](https://github.com/zimfw/completion/blob/33737e8c15fa8dba9af47bef8408b1af2599c21b/init.zsh#L11),
right before `compinit` is run, to more accurately do `zimfw check-dumpfile`.
## [1.11.0] - 2022-12-18

View File

@ -22,8 +22,7 @@ _zimfw_build_init() {
fi
done
zpre=$'*\0'
print -R 'typeset -gr _zim_fpath=('${${_zfpaths#${~zpre}}:A}')'
if (( ${#_zfpaths} )) print 'fpath=(${_zim_fpath} ${fpath})'
if (( ${#_zfpaths} )) print 'fpath=('${${_zfpaths#${~zpre}}:A}' ${fpath})'
if (( ${#zfunctions} )) print -R 'autoload -Uz -- '${zfunctions#${~zpre}}
for zroot_dir in ${_zroot_dirs}; do
zpre=${zroot_dir}$'\0'

View File

@ -2,19 +2,17 @@ _zimfw_check_dumpfile() {
local zdumpfile zfpath zline
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=<%= home %>/.zcompdump
if [[ -e ${zdumpfile} ]]; then
if (( ${+_zim_fpath} )); then
local -r zpre=$'*\0'
zfpath=(${${_zfpaths#${~zpre}}:A} ${fpath:|_zim_fpath})
if (( ${+_zim_dumpfile_fpath} )); then
local -r zcomps=(${^_zim_dumpfile_fpath}/^([^_]*|*~|*.zwc(|.old))(N:t))
IFS=$' \t' read -rA zline < ${zdumpfile} || return 1
if [[ ${zline[2]} -eq ${#zcomps} && ${zline[4]} == ${ZSH_VERSION} ]]; then
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b Already up to date"
else
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b New completion configuration needs to be dumped. Will do %Bclean-dumpfile%b."
_zimfw_clean_dumpfile
fi
else
zfpath=(${fpath})
fi
local -r zcomps=(${^zfpath}/^([^_]*|*~|*.zwc(|.old))(N:t))
IFS=$' \t' read -rA zline < ${zdumpfile} || return 1
if [[ ${zline[2]} -eq ${#zcomps} && ${zline[4]} == ${ZSH_VERSION} ]]; then
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b Already up to date"
else
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b New completion configuration needs to be dumped. Will do %Bclean-dumpfile%b."
_zimfw_clean_dumpfile
_zimfw_print -u2 -PR "%F{yellow}<%= warn %>%B${zdumpfile}:%b Unable to check. This only works when the completion module is initialized."
fi
else
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b Not found"

View File

@ -74,8 +74,7 @@ _zimfw_build_init() {
fi
done
zpre=$'*\0'
print -R 'typeset -gr _zim_fpath=('${${_zfpaths#${~zpre}}:A}')'
if (( ${#_zfpaths} )) print 'fpath=(${_zim_fpath} ${fpath})'
if (( ${#_zfpaths} )) print 'fpath=('${${_zfpaths#${~zpre}}:A}' ${fpath})'
if (( ${#zfunctions} )) print -R 'autoload -Uz -- '${zfunctions#${~zpre}}
for zroot_dir in ${_zroot_dirs}; do
zpre=${zroot_dir}$'\0'
@ -406,19 +405,17 @@ _zimfw_check_dumpfile() {
local zdumpfile zfpath zline
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=${ZDOTDIR:-${HOME}}/.zcompdump
if [[ -e ${zdumpfile} ]]; then
if (( ${+_zim_fpath} )); then
local -r zpre=$'*\0'
zfpath=(${${_zfpaths#${~zpre}}:A} ${fpath:|_zim_fpath})
if (( ${+_zim_dumpfile_fpath} )); then
local -r zcomps=(${^_zim_dumpfile_fpath}/^([^_]*|*~|*.zwc(|.old))(N:t))
IFS=$' \t' read -rA zline < ${zdumpfile} || return 1
if [[ ${zline[2]} -eq ${#zcomps} && ${zline[4]} == ${ZSH_VERSION} ]]; then
_zimfw_print -PR "%F{green})%f %B${zdumpfile}:%b Already up to date"
else
_zimfw_print -PR "%F{green})%f %B${zdumpfile}:%b New completion configuration needs to be dumped. Will do %Bclean-dumpfile%b."
_zimfw_clean_dumpfile
fi
else
zfpath=(${fpath})
fi
local -r zcomps=(${^zfpath}/^([^_]*|*~|*.zwc(|.old))(N:t))
IFS=$' \t' read -rA zline < ${zdumpfile} || return 1
if [[ ${zline[2]} -eq ${#zcomps} && ${zline[4]} == ${ZSH_VERSION} ]]; then
_zimfw_print -PR "%F{green})%f %B${zdumpfile}:%b Already up to date"
else
_zimfw_print -PR "%F{green})%f %B${zdumpfile}:%b New completion configuration needs to be dumped. Will do %Bclean-dumpfile%b."
_zimfw_clean_dumpfile
_zimfw_print -u2 -PR "%F{yellow}! %B${zdumpfile}:%b Unable to check. This only works when the completion module is initialized."
fi
else
_zimfw_print -PR "%F{green})%f %B${zdumpfile}:%b Not found"
@ -457,7 +454,7 @@ _zimfw_compile() {
}
_zimfw_info() {
print -R 'zimfw version: '${_zversion}' (built at 2022-12-18 21:05:25 UTC, previous commit is e54958b)'
print -R 'zimfw version: '${_zversion}' (built at 2023-02-03 23:52:16 UTC, previous commit is 281cde5)'
print -R 'OSTYPE: '${OSTYPE}
print -R 'TERM: '${TERM}
print -R 'TERM_PROGRAM: '${TERM_PROGRAM}