summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKoichi Murase <myoga.murase@gmail.com>2024-01-02 17:40:40 +0900
committerGitHub <noreply@github.com>2024-01-02 08:40:40 +0000
commit7f443588cf591b53ff77614d42ddc7823f20394f (patch)
treee17b40cb1a344a7db51607b362a1b3ef9c52c808
parentd9dab6c92da773918a2c2a53509f286d2ac912f9 (diff)
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
-rw-r--r--atuin/src/shell/atuin.bash3
-rw-r--r--atuin/src/shell/atuin.zsh10
2 files changed, 8 insertions, 5 deletions
diff --git a/atuin/src/shell/atuin.bash b/atuin/src/shell/atuin.bash
index 6257d2c9..d05859d2 100644
--- a/atuin/src/shell/atuin.bash
+++ b/atuin/src/shell/atuin.bash
@@ -86,6 +86,9 @@ __atuin_history() {
# shellcheck disable=SC2048,SC2086
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__:* ]]
then
HISTORY=${HISTORY#__atuin_accept__:}
diff --git a/atuin/src/shell/atuin.zsh b/atuin/src/shell/atuin.zsh
index 7091382a..491ff9ac 100644
--- a/atuin/src/shell/atuin.zsh
+++ b/atuin/src/shell/atuin.zsh
@@ -49,12 +49,12 @@ _atuin_search() {
if [[ -n $output ]]; then
RBUFFER=""
LBUFFER=$output
- fi
- if [[ $LBUFFER == __atuin_accept__:* ]]
- then
- LBUFFER=${LBUFFER#__atuin_accept__:}
- zle accept-line
+ if [[ $LBUFFER == __atuin_accept__:* ]]
+ then
+ LBUFFER=${LBUFFER#__atuin_accept__:}
+ zle accept-line
+ fi
fi
}