Bug 459217 - resizing when a bash prompt is too long produces lots of garbled text
Summary: resizing when a bash prompt is too long produces lots of garbled text
Status: CONFIRMED
Alias: None
Product: konsole
Classification: Applications
Component: emulation (show other bugs)
Version: master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
: 438974 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-09-16 15:19 UTC by Marco Martin
Modified: 2023-10-13 07:55 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Graphical steps to trigger the bug (459.54 KB, image/png)
2022-09-16 15:26 UTC, Marco Martin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marco Martin 2022-09-16 15:19:38 UTC
when tthe bash prompt is very long (for instance being in a very long path) is possible to make the rendering misbehave a lot by painting over and over the bash prompt over many lines.
It seems to also depend from colored bash prompt, here is my PS1:

PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[01;33m\]$(__git_ps1)\[\033[01;34m\] \$\[\033[00m\] '

Steps:
1) reduce the window size to make the bash prompt wordwrap
2) copy some text from konsole
3) paste it so that the pasted text wraps as well
4) enlarge the window
5) shrink it again, pieces of the bash prompt will be painted on multiple lines
Comment 1 Marco Martin 2022-09-16 15:26:29 UTC
Created attachment 152109 [details]
Graphical steps to trigger the bug
Comment 2 Marco Martin 2022-09-16 15:31:50 UTC
When the konsole window is in this garbled state, another issue happens:

if i copy a text that wraps on the two last lines, then when i past it it will have a \n character corresponding to where it was wrapping.

This because in Screen.cpp _lineProperties will *not* have the LINE_WRAPPED on the last wrapped line.

I was originally investigating this as i had a report on this happening (not together the descived bug) but this glitch is the only way i made this happening, so they may be related but not 100% sure
Comment 3 Marco Martin 2022-09-19 13:56:25 UTC
further investigating, when the garbled text happens, this is what Pty::dataReceived() sees arriving from bash:

\r\u001B[K\u001B[A\u001B[01;32mdiau@phobos\u001B[01;34m ~/git/kf5/build/kde/applications/konsole/thisisaverylongdirectorynametoreproducebugs\u001B[01;33m\u001B[01;34m $\u001B[00m t/kf5/build/kde/appli\r\n\rcations/konsole/thisisaverylongdirectorynametoreproduceb


note the point kde/appli\r\n\rcations/konsole   this is where the word wrap of the long command happened, and since konsole informs bash about the window size, bash will produce text "already wrapped" so that konsole doesn't know anymore the last line is wrapped, producing probably the \n in the copied text and making the prompt redraw in the wrong line when resizing producing the garbled text
Comment 4 Kurt Hindenburg 2022-09-26 23:20:39 UTC
Yes, I think there are other BR about this or at least I recall seeing this issue before.
Comment 5 Marco Martin 2023-10-13 07:55:41 UTC
*** Bug 438974 has been marked as a duplicate of this bug. ***