Further improve check-dumpfile action accuracy
Previous change fixed the old dumpfile vs. new dumpfile check, but removed an existing (but flawled) old Zim fpath vs. new Zim fpath check. We should be doing both checks the right way now.
This commit is contained in:
parent
05164357b8
commit
e47eaae2e4
4 changed files with 57 additions and 25 deletions
|
@ -22,7 +22,8 @@ _zimfw_build_init() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
zpre=$'*\0'
|
zpre=$'*\0'
|
||||||
if (( ${#_zfpaths} )) print 'fpath=('${${_zfpaths#${~zpre}}:A}' ${fpath})'
|
print -R 'typeset -gr _zim_fpath=('${${_zfpaths#${~zpre}}:A}')'
|
||||||
|
if (( ${#_zfpaths} )) print 'fpath=(${_zim_fpath} ${fpath})'
|
||||||
if (( ${#zfunctions} )) print -R 'autoload -Uz -- '${zfunctions#${~zpre}}
|
if (( ${#zfunctions} )) print -R 'autoload -Uz -- '${zfunctions#${~zpre}}
|
||||||
for zroot_dir in ${_zroot_dirs}; do
|
for zroot_dir in ${_zroot_dirs}; do
|
||||||
zpre=${zroot_dir}$'\0'
|
zpre=${zroot_dir}$'\0'
|
||||||
|
|
|
@ -1,19 +1,34 @@
|
||||||
_zimfw_check_dumpfile() {
|
_zimfw_check_dumpfile() {
|
||||||
local zdumpfile zfpath zline
|
local zdumpfile
|
||||||
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=<%= home %>/.zcompdump
|
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=<%= home %>/.zcompdump
|
||||||
if [[ -e ${zdumpfile} ]]; then
|
if [[ -e ${zdumpfile} ]]; then
|
||||||
if (( ${+_zim_dumpfile_fpath} )); then
|
local -i zup_to_date=-1
|
||||||
local -r zcomps=(${^_zim_dumpfile_fpath}/^([^_]*|*~|*.zwc(|.old))(N:t))
|
local zline
|
||||||
IFS=$' \t' read -rA zline < ${zdumpfile} || return 1
|
IFS=$' \t' read -rA zline < ${zdumpfile} || return 1
|
||||||
if [[ ${zline[2]} -eq ${#zcomps} && ${zline[4]} == ${ZSH_VERSION} ]]; then
|
if [[ ${zline[4]} != ${ZSH_VERSION} ]] zup_to_date=0
|
||||||
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b Already up to date"
|
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
|
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_print -PR "<%= okay %>%B${zdumpfile}:%b New completion configuration needs to be dumped. Will do %Bclean-dumpfile%b."
|
||||||
_zimfw_clean_dumpfile
|
_zimfw_clean_dumpfile
|
||||||
fi
|
;;
|
||||||
else
|
esac
|
||||||
_zimfw_print -u2 -PR "%F{yellow}<%= warn %>%B${zdumpfile}:%b Unable to check. This only works when the completion module is initialized."
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b Not found"
|
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b Not found"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -4,7 +4,7 @@ class Zim
|
||||||
:clear_line, :ellipsis, :okay, :warn, :error, :done, :failed
|
:clear_line, :ellipsis, :okay, :warn, :error, :done, :failed
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@version = "1.11.1"
|
@version = "1.11.2-SNAPSHOT"
|
||||||
@home = "${ZDOTDIR:-${HOME}}"
|
@home = "${ZDOTDIR:-${HOME}}"
|
||||||
@min_zsh_version = "5.2"
|
@min_zsh_version = "5.2"
|
||||||
# Matches {ssh,http,https,git}://{user@,}host/org/repo and {user@,}host:org/repo
|
# Matches {ssh,http,https,git}://{user@,}host/org/repo and {user@,}host:org/repo
|
||||||
|
|
42
zimfw.zsh
42
zimfw.zsh
|
@ -74,7 +74,8 @@ _zimfw_build_init() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
zpre=$'*\0'
|
zpre=$'*\0'
|
||||||
if (( ${#_zfpaths} )) print 'fpath=('${${_zfpaths#${~zpre}}:A}' ${fpath})'
|
print -R 'typeset -gr _zim_fpath=('${${_zfpaths#${~zpre}}:A}')'
|
||||||
|
if (( ${#_zfpaths} )) print 'fpath=(${_zim_fpath} ${fpath})'
|
||||||
if (( ${#zfunctions} )) print -R 'autoload -Uz -- '${zfunctions#${~zpre}}
|
if (( ${#zfunctions} )) print -R 'autoload -Uz -- '${zfunctions#${~zpre}}
|
||||||
for zroot_dir in ${_zroot_dirs}; do
|
for zroot_dir in ${_zroot_dirs}; do
|
||||||
zpre=${zroot_dir}$'\0'
|
zpre=${zroot_dir}$'\0'
|
||||||
|
@ -402,21 +403,36 @@ _zimfw_version_check() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_zimfw_check_dumpfile() {
|
_zimfw_check_dumpfile() {
|
||||||
local zdumpfile zfpath zline
|
local zdumpfile
|
||||||
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=${ZDOTDIR:-${HOME}}/.zcompdump
|
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=${ZDOTDIR:-${HOME}}/.zcompdump
|
||||||
if [[ -e ${zdumpfile} ]]; then
|
if [[ -e ${zdumpfile} ]]; then
|
||||||
if (( ${+_zim_dumpfile_fpath} )); then
|
local -i zup_to_date=-1
|
||||||
local -r zcomps=(${^_zim_dumpfile_fpath}/^([^_]*|*~|*.zwc(|.old))(N:t))
|
local zline
|
||||||
IFS=$' \t' read -rA zline < ${zdumpfile} || return 1
|
IFS=$' \t' read -rA zline < ${zdumpfile} || return 1
|
||||||
if [[ ${zline[2]} -eq ${#zcomps} && ${zline[4]} == ${ZSH_VERSION} ]]; then
|
if [[ ${zline[4]} != ${ZSH_VERSION} ]] zup_to_date=0
|
||||||
_zimfw_print -PR "%F{green})%f %B${zdumpfile}:%b Already up to date"
|
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
|
else
|
||||||
|
zup_to_date=0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
case ${zup_to_date} in
|
||||||
|
-1) _zimfw_print -u2 -PR "%F{yellow}! %B${zdumpfile}:%b Unable to check. Initialize the completion module first." ;;
|
||||||
|
1) _zimfw_print -PR "%F{green})%f %B${zdumpfile}:%b Already up to date" ;;
|
||||||
|
0)
|
||||||
_zimfw_print -PR "%F{green})%f %B${zdumpfile}:%b New completion configuration needs to be dumped. Will do %Bclean-dumpfile%b."
|
_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_clean_dumpfile
|
||||||
fi
|
;;
|
||||||
else
|
esac
|
||||||
_zimfw_print -u2 -PR "%F{yellow}! %B${zdumpfile}:%b Unable to check. This only works when the completion module is initialized."
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
_zimfw_print -PR "%F{green})%f %B${zdumpfile}:%b Not found"
|
_zimfw_print -PR "%F{green})%f %B${zdumpfile}:%b Not found"
|
||||||
fi
|
fi
|
||||||
|
@ -454,7 +470,7 @@ _zimfw_compile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_zimfw_info() {
|
_zimfw_info() {
|
||||||
print -R 'zimfw version: '${_zversion}' (built at 2023-02-04 14:46:47 UTC, previous commit is 7778e97)'
|
print -R 'zimfw version: '${_zversion}' (built at 2023-02-07 00:18:49 UTC, previous commit is 0516435)'
|
||||||
print -R 'OSTYPE: '${OSTYPE}
|
print -R 'OSTYPE: '${OSTYPE}
|
||||||
print -R 'TERM: '${TERM}
|
print -R 'TERM: '${TERM}
|
||||||
print -R 'TERM_PROGRAM: '${TERM_PROGRAM}
|
print -R 'TERM_PROGRAM: '${TERM_PROGRAM}
|
||||||
|
@ -841,7 +857,7 @@ esac
|
||||||
|
|
||||||
zimfw() {
|
zimfw() {
|
||||||
builtin emulate -L zsh -o EXTENDED_GLOB
|
builtin emulate -L zsh -o EXTENDED_GLOB
|
||||||
local -r _zversion='1.11.1' zusage="Usage: %B${0}%b <action> [%B-q%b|%B-v%b]
|
local -r _zversion='1.11.2-SNAPSHOT' zusage="Usage: %B${0}%b <action> [%B-q%b|%B-v%b]
|
||||||
|
|
||||||
Actions:
|
Actions:
|
||||||
%Bbuild%b Build %B${ZIM_HOME}/init.zsh%b and %B${ZIM_HOME}/login_init.zsh%b.
|
%Bbuild%b Build %B${ZIM_HOME}/init.zsh%b and %B${ZIM_HOME}/login_init.zsh%b.
|
||||||
|
|
Loading…
Reference in a new issue