Bug 392419

Summary: Line-filling trailing spaces are picked up by "copy" operation after konsole window resize.
Product: [Applications] konsole Reporter: David Tonhofer <bughunt>
Component: copy-pasteAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED FIXED    
Severity: normal CC: mglb
Priority: NOR    
Version: 17.12.2   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Screenshots illustrating the bug

Description David Tonhofer 2018-03-27 16:47:15 UTC
Even with "trim trailing spaces" enabled:

1) Have a small window
2) With some output, e.g. the output of tree --help
3) Resize window, making it larger
4) tree --help again
5) Copy-paste the contents back into the history
6) The lowermost lines have no trailing space, but from some point onwards, trailing spaces have been inject to fill space and are also picked up by the copy operation. This is not necessarily the line that is not visible after command execution, it may be a few lines earlier (may depend on some buffer size)
X) This is easily seen when pasting into LibreOffice Word with "Toggle formatting marks" on (the Paragraph sign clicked) and View>FieldShadings on
Comment 1 Mariusz Glebocki 2018-03-28 23:39:11 UTC
Created attachment 111712 [details]
Screenshots illustrating the bug

Confirmed on current master.
Affected are empty lines added to a buffer when resizing.

I've attached screenshots illustrating the bug. Command executed in terminal: tree --help; echo '---RESIZE---'; sleep 10; tree --help
1) initial window size
2) window resized during sleep
3) copy-pasted terminal contents in vim (magenta = trailing spaces). Amount of spaces in lines shows approximately how the window was resized.
Comment 2 Kurt Hindenburg 2018-04-03 21:15:01 UTC
Git commit 61069543e01583644467df16e50f6708622aba31 by Kurt Hindenburg, on behalf of Mariusz Glebocki.
Committed on 03/04/2018 at 21:14.
Pushed by hindenburg into branch 'master'.

Do not resize new screen lines

Summary:
The lines are resized when something is put in them. Resizing them
here filled them with spaces (default value), later those trailing
spaces were put into history, and eventually into saved output or
clipboard (because it is assumed lines in history do not contain
trailing spaces).

Test Plan:
* Enable "Trim trailing spaces" in Profile Settings → Mouse
* Set window size to about 100x100px
* Clear terminal (Ctrl-Shift-K by default)
* Run:
```
seq $(( $(tput lines) * 2 )); \
printf '*** resize ***'; read -s; printf '\n'; \
seq $(( $(tput lines) * 2 ))
```
* When "resize" show up, resize the window to about 500x500px
* Press enter
* Select and copy lines below `*** resize ***`
* Paste it in a text editor which allows to show trailing spaces

Expected result: lines should not contain trailing spaces
Actual result: lines added when resizing the window have trailing spaces

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D11893

M  +0    -3    src/Screen.cpp

https://commits.kde.org/konsole/61069543e01583644467df16e50f6708622aba31
Comment 3 Kurt Hindenburg 2018-04-08 00:51:55 UTC
Git commit b7f40e0f097e8887854b7949d8b31d5521341349 by Kurt Hindenburg, on behalf of Mariusz Glebocki.
Committed on 08/04/2018 at 00:47.
Pushed by hindenburg into branch 'Applications/18.04'.

Do not resize new screen lines

Summary:
The lines are resized when something is put in them. Resizing them
here filled them with spaces (default value), later those trailing
spaces were put into history, and eventually into saved output or
clipboard (because it is assumed lines in history do not contain
trailing spaces).

Test Plan:
* Enable "Trim trailing spaces" in Profile Settings → Mouse
* Set window size to about 100x100px
* Clear terminal (Ctrl-Shift-K by default)
* Run:
```
seq $(( $(tput lines) * 2 )); \
printf '*** resize ***'; read -s; printf '\n'; \
seq $(( $(tput lines) * 2 ))
```
* When "resize" show up, resize the window to about 500x500px
* Press enter
* Select and copy lines below `*** resize ***`
* Paste it in a text editor which allows to show trailing spaces

Expected result: lines should not contain trailing spaces
Actual result: lines added when resizing the window have trailing spaces

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D11893

(cherry picked from commit 61069543e01583644467df16e50f6708622aba31)

M  +0    -3    src/Screen.cpp

https://commits.kde.org/konsole/b7f40e0f097e8887854b7949d8b31d5521341349