st-flexipatch
st-flexipatch copied to clipboard
Reflow patch: replicated shell prompt
The shell prompt gets replicated when I resize the window with reflow patch enabled.
Reproduce: patches.h.txt
- Enable patch. patches.h.txt
- Run
st -c fish &
. - Press Enter to show two prompt lines in the terminal.
- Resize small enough to affect the prompt area, resize larger, repeat a few times.
Video: https://github.com/bakkeby/st-flexipatch/assets/1414102/3f37b42b-a4ba-409c-af7c-5ef8dd9b8e44
I chose fish for the video because the provides a fancy prompt by default. I suspect this issue has to do with ANSI escape codes in the prompt variable. I can reproduce it in bash and zsh with custom fancy prompts. However, I can't reproduce if the prompt is plain text, such as PS1="long long prompt# "
.
The reason for the issue is that both the terminal and the shell are trying to reflow the prompt at the same time and here is the result. Since the issue still occurs on other terminals (Alacritty, Wezterm, Xfce terminal etc.) as well, I don't think there is an easy solution to it. Kitty tries to mitigate this by using delayed drawing, but it's not perfect either.
Thank you. My fancy prompt is quite short anyway, so I won't see this behavior very often. I note that tmux seems to know how to reflow the prompt correctly.
Yes I have seen this prompt resize issue with practically every terminal I have tested.
Starting to write a command at the middle to right hand side of the terminal never felt that good to me. Adding a newline and having the prompt at the far left means that all commands start from the same position.
Incidentally that also fixed the repeated shell prompt issue for me (across terminals).