bakkeby / st-flexipatch

An st build with preprocessor directives to decide which patches to include during build time
MIT License
347 stars 107 forks source link

Reflow patch: replicated shell prompt #124

Open step- opened 5 months ago

step- commented 5 months ago

The shell prompt gets replicated when I resize the window with reflow patch enabled.

Reproduce: patches.h.txt

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# ".

veltza commented 5 months ago

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.

step- commented 5 months ago

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.

bakkeby commented 5 months ago

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.

image

Incidentally that also fixed the repeated shell prompt issue for me (across terminals).