fix(history): drop jjf entry on cancel/error paths too
Previously, the original `jjf …` invocation only got dropped from history on successful confirm. A cancelled or errored picker left a useless `jjf …` entry behind. Now bash drops it unconditionally via `_jjf_drop_last_history`; fish arms the postexec hook before the `--emit` call so the deletion happens regardless of exit path.
This commit is contained in:
2 files changed
+17
-10
No files matched your search
+4
-3
@@ -9,6 +9,10 @@ function jjf
|
||||
command jjf $argv
|
||||
return $status
|
||||
end
|
||||
# Arm the postexec hook *before* invoking the picker so the original
|
||||
# `jjf …` entry is removed from history on any exit path (cancel, error,
|
||||
# or success). Fish records function invocations *after* return.
|
||||
set -g _jjf_pending_swap 1
|
||||
set -l _jjf_cmd (command jjf --emit $argv)
|
||||
set -l _jjf_status $status
|
||||
if test $_jjf_status -ne 0
|
||||
@@ -18,9 +22,6 @@ function jjf
|
||||
return 130
|
||||
end
|
||||
builtin history append -- $_jjf_cmd
|
||||
# Signal the postexec hook to remove the literal `jjf …` entry that fish
|
||||
# is about to record (fish records function invocations *after* return).
|
||||
set -g _jjf_pending_swap 1
|
||||
sh -c $_jjf_cmd
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user