Error when deleting the last item in a history delete --contains <text>
command
#10189
Labels
bug
Something that's not working as intended
Milestone
How to reproduce (these are the commands to run and the outputs I get)
Deleting any other entry ID works, but not the last one.
I went through the code in
share/functions/history.fish
(locally), and with a little print-debugging, narrowed it down to line 177. It checks whether the ID entered is less than the count. But since these IDs are 1-indexed, that makes the last ID invalid. I think the fix is to changeand test $i -lt $found_items_count
toand test $i -le $found_items_count
.The bug seems to have been introduced in this commit where deleting ranges of history entries was implemented. Earlier, it was a
>
check, and ifID > count
, then it shows the error message. In the current implementation, ifID < count
, only then the ID is valid, which seems to be incorrect.I have the (tiny) fix in a fork: NethumL/fish-shell.
I checked it locally, and the fix works (both in my system-wide installed fish and the one I compiled after implementing the fix).
PR: #10190
System details:
OS: macOS Sonoma 14.1.1 (23B81)
Terminal: Alacritty
The problem can also be reproduced without third-party customisations (using
sh -c 'env HOME=$(mktemp -d) XDG_CONFIG_HOME= fish'
)The text was updated successfully, but these errors were encountered: