mirror of
https://github.com/atuinsh/atuin.git
synced 2024-12-27 09:29:24 +01:00
fix(bash,zsh): fix quirks on search cancel (#1483)
* fix(bash): preserve the line content on search cancel In the current implementation for Bash, the line content is lost when the user cancels the atuin search by pressing ESC, C-g, or Down at the bottom line. This is because the line content is set to the empty string returned by atuin on the cancellation of the search. In the integrations for other shells, zsh and fish, the empty output is properly handled so that the line content is preserved. This patch makes the behavior in Bash consistent with that in zsh and fish, i.e., we do nothing when the atuin search returns an empty output. * fix(zsh): ignore confusing line `__atuin_accept__:*` on search cancel
This commit is contained in:
parent
d9dab6c92d
commit
7f443588cf
@ -86,6 +86,9 @@ __atuin_history() {
|
|||||||
# shellcheck disable=SC2048,SC2086
|
# shellcheck disable=SC2048,SC2086
|
||||||
HISTORY="$(ATUIN_SHELL_BASH=t ATUIN_LOG=error atuin search $* -i -- "${READLINE_LINE}" 3>&1 1>&2 2>&3)"
|
HISTORY="$(ATUIN_SHELL_BASH=t ATUIN_LOG=error atuin search $* -i -- "${READLINE_LINE}" 3>&1 1>&2 2>&3)"
|
||||||
|
|
||||||
|
# We do nothing when the search is canceled.
|
||||||
|
[[ $HISTORY ]] || return 0
|
||||||
|
|
||||||
if [[ $HISTORY == __atuin_accept__:* ]]
|
if [[ $HISTORY == __atuin_accept__:* ]]
|
||||||
then
|
then
|
||||||
HISTORY=${HISTORY#__atuin_accept__:}
|
HISTORY=${HISTORY#__atuin_accept__:}
|
||||||
|
@ -49,12 +49,12 @@ _atuin_search() {
|
|||||||
if [[ -n $output ]]; then
|
if [[ -n $output ]]; then
|
||||||
RBUFFER=""
|
RBUFFER=""
|
||||||
LBUFFER=$output
|
LBUFFER=$output
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $LBUFFER == __atuin_accept__:* ]]
|
if [[ $LBUFFER == __atuin_accept__:* ]]
|
||||||
then
|
then
|
||||||
LBUFFER=${LBUFFER#__atuin_accept__:}
|
LBUFFER=${LBUFFER#__atuin_accept__:}
|
||||||
zle accept-line
|
zle accept-line
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user