Specifically this then causes to not have space in the prompt when you change it.
$ echo "X${PS1}X"
X{display_cwd}{git_branch}$X
$ PS1="$PS1"
$ls
As you can see, it seems $PS1 trims the space at the end, and then it is missing in the prompt. There might be more than one bug in this. We need to ensure that spaces at the end of the string are preserved.