Fix candidate parsing now preserving original history content

The previous expansion condensed repeated white spaces which caused harm to the original history content.
This commit is contained in:
MamoruDS
2023-02-11 03:43:30 +09:00
parent 446da4a412
commit de4c3c7a8a

View File

@@ -59,7 +59,11 @@ fzf_history_search() {
candidates=(${(f)"$(eval $history_cmd | fzf ${=ZSH_FZF_HISTORY_SEARCH_FZF_ARGS} ${=ZSH_FZF_HISTORY_SEARCH_FZF_EXTRA_ARGS} -q "$BUFFER")"})
local ret=$?
if [ -n "$candidates" ]; then
BUFFER="${candidates[@]/(#m)*/${${(As: :)MATCH}[${CANDIDATE_LEADING_FIELDS},-1]}}"
if (( ! $CANDIDATE_LEADING_FIELDS == 1 )); then
BUFFER="${candidates[@]/(#m)[0-9 \-\:]##/${${(As: :)MATCH}[${CANDIDATE_LEADING_FIELDS},-1]}}"
else
BUFFER="${candidates[@]}"
fi
BUFFER="${BUFFER[@]/(#b)(?)\\n/$match[1]
}"
zle vi-fetch-history -n $BUFFER