I've noticed that many times when I'm reverse-history-searching from the command line via CTRL+r, if I want to edit the command, sometimes the cursor jumps to the wrong position when I press an arrow key or enter CTRL+a or CTRL+e. The specific position it jumps to seems to be an offset equal to the size of my command line prompt as set in
This causes difficulty because the actual location of the cursor is different from what is rendered on the screen; future edits to the command are rendered as if the cursor is where it jumped to, but the actual command retains the correct location without any jump.
Does anyone know what's causing this or how to fix it?
EDIT: If I add a newline at the end of
PS1 the problem seems to go away. However, I would prefer to enter the command on the same line as the prompt.