zsh:keys: Use (A) flag instead of hack to split LBUFFER

This way better solution using the `(A)` flag was given to me in the
zsh-users mailing list back in 2022 but I forgot to apply it.

See zshexpn(1):

> Convert the substitution into an array expression, even if it
> otherwise would be scalar.

Thanks Mikael!

Link: https://www.zsh.org/mla/users/2022/msg00668.html
This commit is contained in:
2024-10-30 16:13:16 +01:00
parent d87d2cfee5
commit 1ffd31d585

View File

@@ -159,13 +159,9 @@ function rationalize_dots {
return
fi
# NOTE: This is a hack to fix the (z) expansion flag if the path is the only
# word in LBUFFER, as then [:-1] treats the expansion as a scalar and
# returns the last character (i.e. always `/`).
local lbuffer_words="x $LBUFFER"
# Print currently typed path as absolute path with "collapsed"/reversed
# filename expansion.
zle -M "${(D)${(z)lbuffer_words}[-1]:a}"
zle -M "${(D)${(Az)LBUFFER}[-1]:a}"
}
zle -N rationalize_dots
bindkey . rationalize_dots