Bug 459217

Summary: resizing when a bash prompt is too long produces lots of garbled text
Product: [Applications] konsole Reporter: Marco Martin <notmart>
Component: emulationAssignee: Konsole Developer <konsole-devel>
Status: CONFIRMED ---    
Severity: normal CC: ivan.kryukov84, nate
Priority: NOR    
Version: master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Graphical steps to trigger the 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. ***