Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion includes/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,25 @@ clean_path() {
source_compiled() {
local file="$1"
[[ -f "$file" ]] || return 1
[[ ! -f "${file}.zwc" || "$file" -nt "${file}.zwc" ]] && zcompile "$file"

local zwc_file
# If file is in cache directory, compile alongside it
# Otherwise, compile to cache/compiled/ directory
if [[ "$file" == ${ZSH_CACHE_DIR}/* ]]; then
zwc_file="${file}.zwc"
else
# Create compiled subdirectory in cache
local compiled_dir="${ZSH_CACHE_DIR}/compiled"
[[ -d "$compiled_dir" ]] || mkdir -p "$compiled_dir"

# Generate cache filename from source path (replace / with _)
local rel_path="${file#${ZSH}/}"
local cache_name="${rel_path//\//_}"
zwc_file="${compiled_dir}/${cache_name}.zwc"
fi

# Compile if missing or stale
[[ ! -f "$zwc_file" || "$file" -nt "$zwc_file" ]] && zcompile "$zwc_file" "$file"
source "$file"
}

Expand Down
7 changes: 5 additions & 2 deletions tools/test_config.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,11 @@ if [[ $COMPILE_ERRORS -eq 0 ]]; then
echo "${GREEN}✓${NC} All files compile to .zwc"

if [[ "$FIX_MODE" == false ]]; then
# Clean up test compilation artifacts
find . -name "*.zwc" -newer zshrc -delete 2>/dev/null
# Clean up test compilation artifacts (they belong in cache/, not source dirs)
# Use (N) glob qualifier to make pattern null if no matches (zsh-specific)
local -a cleanup_files
cleanup_files=(zshrc.zwc includes/*.zwc(N) .antidote/*.zwc(N))
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cleanup array initialization should use the (N) glob qualifier for zshrc.zwc as well, or check file existence before attempting removal. Currently, if zshrc.zwc doesn't exist, it will still be added to the array, and the check ${#cleanup_files[@]} > 0 will pass, causing rm -f to be called with a non-existent file. While rm -f silently ignores non-existent files, using the (N) qualifier consistently would be cleaner. Change to: cleanup_files=(zshrc.zwc(N) includes/.zwc(N) .antidote/.zwc(N))

Suggested change
cleanup_files=(zshrc.zwc includes/*.zwc(N) .antidote/*.zwc(N))
cleanup_files=(zshrc.zwc(N) includes/*.zwc(N) .antidote/*.zwc(N))

Copilot uses AI. Check for mistakes.
[[ ${#cleanup_files[@]} -gt 0 ]] && rm -f "${cleanup_files[@]}"
fi
else
ERRORS=$((ERRORS + COMPILE_ERRORS))
Expand Down
4 changes: 3 additions & 1 deletion zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ fi

# Load core functions
ZSH_INIT_FILE="${ZSH_INCLUDES}/init.zsh"
[[ ! -f "${ZSH_INIT_FILE}.zwc" || "${ZSH_INIT_FILE}" -nt "${ZSH_INIT_FILE}.zwc" ]] && zcompile "${ZSH_INIT_FILE}"
ZSH_INIT_COMPILED="${ZSH_CACHE_DIR}/compiled/includes_init.zsh.zwc"
[[ -d "${ZSH_CACHE_DIR}/compiled" ]] || mkdir -p "${ZSH_CACHE_DIR}/compiled"
[[ ! -f "${ZSH_INIT_COMPILED}" || "${ZSH_INIT_FILE}" -nt "${ZSH_INIT_COMPILED}" ]] && zcompile "${ZSH_INIT_COMPILED}" "${ZSH_INIT_FILE}"
source "${ZSH_INIT_FILE}"

# Combine, and compile all includes
Expand Down