Skip to content

refactor(core): consolidate duplicate helpers and naming drift #449

Description

@ss-o

Current limitation

The audit found low-severity duplication and naming drift that make ownership and future maintenance less reliable:

  • .zi-at-eval is independently defined in both lib/zsh/autoload.zsh and lib/zsh/install.zsh.
  • The header above @zsh-plugin-run-on-unload names the update callback.
  • The parallel updater header names .zi-update-in-parallel, while the function is .zi-update-all-parallel.
  • .zi-load-ices contains an unresolved snippet-directory computation TODO that needs an ID-collision test before it can be classified as a defect.

Evidence at commit 795662792e70af6cd36155b019b775796a9fdbee:

  • zi/lib/zsh/autoload.zsh

    Lines 259 to 266 in 7956627

    # FUNCTION: .zi-at-eval [[[
    .zi-at-eval() {
    local atclone="$2" atpull="$1"
    integer retval
    @zi-substitute atclone atpull
    [[ $atpull = "%atclone" ]] && { eval "$atclone"; retval=$?; } || { eval "$atpull"; retval=$?; }
    return $retval
    } # ]]]
  • zi/lib/zsh/install.zsh

    Lines 2046 to 2055 in 7956627

    # FUNCTION: .zi-at-eval [[[
    .zi-at-eval() {
    local atpull="$1" atclone="$2"
    integer retval
    @zi-substitute atclone atpull
    local cmd="$atpull"
    [[ $atpull == "%atclone" ]] && cmd="$atclone"
    eval "$cmd"
    return "$?"
    } # ]]]
  • zi/zi.zsh

    Lines 1154 to 1166 in 7956627

    # FUNCTION: @zsh-plugin-run-on-update. [[[
    # The Plugin Standard required mechanism, see:
    # https://wiki.zshell.dev/community/zsh_plugin_standard
    @zsh-plugin-run-on-unload() {
    ICE[ps-on-unload]="${(j.; .)@}"
    .zi-pack-ice "$id_as" ""
    } # ]]]
    # FUNCTION: @zsh-plugin-run-on-update. [[[
    # The Plugin Standard required mechanism
    @zsh-plugin-run-on-update() {
    ICE[ps-on-update]="${(j.; .)@}"
    .zi-pack-ice "$id_as" ""
    } # ]]]
  • zi/lib/zsh/autoload.zsh

    Lines 1846 to 1848 in 7956627

    # FUNCTION: .zi-update-in-parallel [[[
    .zi-update-all-parallel() {
    builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
  • zi/zi.zsh

    Lines 2025 to 2044 in 7956627

    # second-next command (that's why it's called "ice" - it melts), however they glue to the object (plugin
    # or snippet) mentioned in the next command – for later use with e.g. `zi update ...'.
    .zi-pack-ice() {
    ZI_SICE[$1${1:+${2:+/}}$2]+="${(j: :)${(qkv)ICE[@]}} "
    ZI_SICE[$1${1:+${2:+/}}$2]="${ZI_SICE[$1${1:+${2:+/}}$2]# }"
    return 0
    } # ]]]
    # FUNCTION: .zi-load-ices. [[[
    .zi-load-ices() {
    local id_as="$1" ___key ___path
    local -a ice_order
    ice_order=(
    ${(As:|:)ZI[ice-list]}
    ${(@)${(@Akons:|:u)${ZI_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}
    )
    ___path="${ZI[PLUGINS_DIR]}/${id_as//\//---}"/._zi
    # TODO Snippet's dir computation…
    if [[ ! -d $___path ]] {
    if ! .zi-get-object-path snippet "${id_as//\//---}"; then
    return 1

Proposed improvement

  • Establish one owning definition for .zi-at-eval and source it consistently.
  • Correct function headers as part of the owning behavioral fixes.
  • Add a focused test for plugin/snippet effective-ID collisions before deciding whether .zi-load-ices needs a type-aware API.
  • Keep compatibility aliases separate from accidental duplicate implementations.

Acceptance criteria

  • One canonical .zi-at-eval implementation remains.
  • Function headers match their definitions.
  • The snippet ICE TODO is either resolved with a regression test or replaced by a precise tracked limitation.
  • Existing syntax, load, update, and extraction tests remain green.

Next action

Write the effective-ID collision test first, then consolidate only the duplication proven unnecessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:ziZi core behavior, APIs, or documentation.type:maintenanceNon-feature maintenance, cleanup, or org work.

    Type

    No type

    Projects

    Status
    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions