My setup:
- zsh 5.7.1 (x86_64-apple-darwin19.0)
- macOS Catalina 10.15.5
Here's the standard PS1 var: PS1="%n@%m %~ %# "
Problems arise when I try adding text coloring using either ANSI colors or tput. Example (without terminating the color, it behaves oddly regardless of that):
PS1="%n@%m \e[38;5;197m%~ %# "
Here's what happens when I use Ctrl+R (reverse search):

What could be the reason for this indent?
Second problem happens when a long string in the prompt goes to the newline - new character after newline overlaps the first line and I can't see the latter. This happens only with the first newline, third one appears normally (but in second place).
I tried using this answer but the solution can't get parsed by the shell: rombez@MacBook-Pro \[\e[38;5;197m\]~