This strange (to me) behaviour has bamboozled me for years.
In bash, one can press up to refer to the previous command. Say then I accidentally press Ctrl+W and I wish to restore the previous command, but it seems to be gone. If I clear the command, and try again, it's still gone from the history.
E.g.
Let's say I run the following command:
$ ls /etc/sudoers.d/
10_at-export 010_pi-nopasswd 010_proxy README
Now press Up:
$ ls /etc/sudoers.d/
Now press Up then Backspace a few times:
$ ls
Now how to return to ls /etc/sudoers.d/
from here?
For a long command, I resort to mouse copying and pasting of the above command #mouseisuncool.