Skip to content

Commit 8bacfb3

Browse files
committed
Fix multi-line command bug
Before, selecting a multi-line command when using the search command history feature would result in the command lined being replaced with only the top line of the selected command. For example, selecting this command from history... function example echo "This is just an example" end ...would result in the command line becoming... function example with the rest of the command lost. The bug occurred because when a command substitution has a multi-line output and is assigned to a variable, each line of the output is give its own index in the variable. So, referencing index 2 only gave us one line of the command. To fix this, we have to string collect the multi-line output into a single string before assigning it. This fixes the bug by doing just that so users can now select the entirety of multi-line commands from history.
1 parent d89cd0c commit 8bacfb3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

functions/__fzf_search_history.fish

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ function __fzf_search_history --description "Search command history. Replace the
44
set command_with_ts (
55
# Reference https://devhints.io/strftime to understand strftime format symbols
66
builtin history --null --show-time="%m-%d %H:%M:%S | " |
7-
fzf --read0 --tiebreak=index --query=(commandline)
7+
fzf --read0 --tiebreak=index --query=(commandline) |
8+
string collect
89
)
910

1011
if test $status -eq 0

0 commit comments

Comments
 (0)