From c24960c32466523f6e765ba51e81739dd4ff9923 Mon Sep 17 00:00:00 2001 From: "ohmyzsh[bot]" <54982679+ohmyzsh[bot]@users.noreply.github.com> Date: Mon, 4 May 2026 09:19:36 +0200 Subject: [PATCH] chore(z): update to version acd0e198 (#13725) Co-authored-by: ohmyzsh[bot] <54982679+ohmyzsh[bot]@users.noreply.github.com> --- .github/dependencies.yml | 2 +- plugins/z/MANUAL.md | 8 +++++--- plugins/z/z.plugin.zsh | 27 ++++++++++++++++++--------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/dependencies.yml b/.github/dependencies.yml index 4a3c89eb7..124c78eba 100644 --- a/.github/dependencies.yml +++ b/.github/dependencies.yml @@ -46,7 +46,7 @@ dependencies: plugins/z: branch: master repo: agkozak/zsh-z - version: 519e5796df3db6c68317c7a3901444fab3241bbc + version: acd0e1984df350c189f8f9c4956ec586b6c73fca precopy: | set -e test -e README.md && mv -f README.md MANUAL.md diff --git a/plugins/z/MANUAL.md b/plugins/z/MANUAL.md index 790d4d389..420535b27 100644 --- a/plugins/z/MANUAL.md +++ b/plugins/z/MANUAL.md @@ -33,11 +33,13 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
Here are the latest features and updates. +- May 1, 2026 + + Various tab completion bugs resolved. - April 27, 2026 - + Fixes a bug where re-sourcing the script caused an infinite loop when Tab was pressed. Props to @maheshpec for [successfully diagnosing the problem](https://github.com/ohmyzsh/ohmyzsh/pull/13715). - + Fixes a bug where the completion widget was not identifying flags correctly. + + Fixes a bug where re-sourcing the script caused an infinite loop when tab was pressed. Props to @maheshpec for [successfully diagnosing the problem](https://github.com/ohmyzsh/ohmyzsh/pull/13715). + + Fixes a bug where the completion widget was not identifying options correctly. - March 31, 2026 - + When the user hits Tab after entering a command-line argument that uses spaces as wildcards (e.g., `z us lo bi`), the command line is clear of detritus (i.e., it looks like `z /usr/local/bin` instead of `z us lo /usr/local/bin`). + + When the user hits tab after entering a command-line argument that uses spaces as wildcards (e.g., `z us lo bi`), the command line is clear of detritus (i.e., it looks like `z /usr/local/bin` instead of `z us lo /usr/local/bin`). + Improved test for Docker containers. - August 24, 2023 + Zsh-z will now run when `setopt NO_UNSET` has been enabled (props @ntninja). diff --git a/plugins/z/z.plugin.zsh b/plugins/z/z.plugin.zsh index e1a9bd076..6df49822e 100644 --- a/plugins/z/z.plugin.zsh +++ b/plugins/z/z.plugin.zsh @@ -96,7 +96,7 @@ With no ARGUMENT, list the directory history in ascending rank. -t Match by recent access -x Remove a directory from the database (by default, the current directory) -xR Remove a directory and its subdirectories from the database (by default, the current directory)" | - fold -s -w $COLUMNS >&2 + fold -s -w $(( COLUMNS > 0 ? COLUMNS : 80 )) >&2 } # Load zsh/datetime module, if necessary @@ -251,7 +251,7 @@ zshz() { if (( ${ZSHZ_NO_RESOLVE_SYMLINKS:-${_Z_NO_RESOLVE_SYMLINKS}} )); then [[ -d ${${*:-${PWD}}:a} ]] && xdir=${${*:-${PWD}}:a} else - [[ -d ${${*:-${PWD}}:A} ]] && xdir=${${*:-${PWD}}:a} + [[ -d ${${*:-${PWD}}:A} ]] && xdir=${${*:-${PWD}}:A} fi local -a lines_to_keep @@ -741,6 +741,9 @@ zshz() { for opt in ${(k)opts}; do case $opt in --add) + # Don't change the database when invoked via --complete (e.g., from + # tab completion). + (( ${+opts[--complete]} )) && continue [[ ! -d $* ]] && return 1 local dir # Cygwin and MSYS2 have a hard time with relative paths expressed from / @@ -764,6 +767,7 @@ zshz() { ;; -c) [[ $* == ${PWD}/* || $PWD == '/' ]] || prefix="$PWD " ;; -h|--help) + (( ${+opts[--complete]} )) && continue _zshz_usage return ;; @@ -771,6 +775,7 @@ zshz() { -r) method='rank' ;; -t) method='time' ;; -x) + (( ${+opts[--complete]} )) && continue # Cygwin and MSYS2 have a hard time with relative paths expressed from / if [[ $OSTYPE == (cygwin|msys) && $PWD == '/' && $* != /* ]]; then set -- "/$*" @@ -844,7 +849,8 @@ zshz() { # New experimental "uncommon" behavior # - # If the best choice at this point is something like /foo/bar/foo/bar, and the # search pattern is `bar', go to /foo/bar/foo/bar; but if the search pattern + # If the best choice at this point is something like /foo/bar/foo/bar, and the + # search pattern is `bar', go to /foo/bar/foo/bar; but if the search pattern # is `foo', go to /foo/bar/foo if (( ZSHZ_UNCOMMON )) && [[ -n $cd ]]; then if [[ -n $cd ]]; then @@ -996,21 +1002,24 @@ _zshz_zle_completion_widget() { # Only act when there are at least two words after the command if [[ $LBUFFER == ${cmd}\ *\ * ]]; then local after=${LBUFFER#${cmd} } - local -a parts flag_parts search_parts - local p past_flags=0 + local -a parts option_parts search_parts + local p past_options=0 parts=( ${(z)after} ) for p in $parts; do - if (( ! past_flags )) && [[ $p == (-[cehlrRtx]##|--add|--complete|--help) ]]; then - flag_parts+=( $p ) + if (( ! past_options )) && [[ $p == (--|-[cehlrRtx]##|--add|--complete|--help) ]]; then + option_parts+=( $p ) + # `--' terminates option parsing; subsequent tokens are positional, + # even if they happen to look like options. + [[ $p == -- ]] && past_options=1 else - past_flags=1 + past_options=1 search_parts+=( $p ) fi done if (( ${#search_parts} > 1 )); then - LBUFFER="${cmd}${flag_parts:+ ${(j: :)flag_parts}} ${(j:*:)search_parts}" + LBUFFER="${cmd}${option_parts:+ ${(j: :)option_parts}} ${(j:*:)search_parts}" fi fi