Bug 399109 - Long line selection using double-click is limited by the window size
Summary: Long line selection using double-click is limited by the window size
Alias: None
Product: konsole
Classification: Applications
Component: copy-paste (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
Keywords: usability
Depends on:
Reported: 2018-09-26 15:31 UTC by Pavel
Modified: 2018-10-22 14:36 UTC (History)
2 users (show)

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

Screenshot of the incomplete selection (277.33 KB, image/png)
2018-09-26 15:31 UTC, Pavel

Note You need to log in before you can comment on or make changes to this bug.
Description Pavel 2018-09-26 15:31:08 UTC
Created attachment 115251 [details]
Screenshot of the incomplete selection


When selecting text in Konsole, double-click only selects the visible part of a long line.

1. Open Konsole
2. Resize window to be small enough
3. Run dd if=/dev/urandom bs=4K count=1 status=none | base64 -w 0
4. Ensure the resulting line is long enough to not fit in the window vertically
5. Double-click in the middle of the displayed line
6. Scroll up


Part of the line that wasn't displayed isn't selected.


The whole line is selected.

(available in About System)
KDE Plasma Version: None
KDE Frameworks Version: 5.44.0
Qt Version: 5.9.5

Konsole versions tried:

Konsole 17.12.3-1 from Ubuntu
Konsole 18.11.70 (trunk 99f233b9a155b8e3ee1ee8f1c624ee58ef3ce4fc)


Triple-click works correctly.
Same actions using GNOME Terminal work as expected.
Comment 1 Kurt Hindenburg 2018-10-11 14:37:22 UTC
Yes, this is a known issue.  A fix was attempted earlier but was reverted due to crashes.
Comment 2 Pavel 2018-10-11 15:22:30 UTC
Could you point me to the attempted fix? I might be able to figure out what was wrong with it.
Comment 4 Pavel 2018-10-12 16:05:51 UTC
I think I got it: https://phabricator.kde.org/D16159
Comment 5 Kurt Hindenburg 2018-10-22 14:36:24 UTC
Git commit 4e09f089f940335bdd628139e870ba99721fddfa by Kurt Hindenburg, on behalf of Pavel Khlebovich.
Committed on 22/10/2018 at 14:36.
Pushed by hindenburg into branch 'master'.

Fix double click can only select text within visible region

This is a reimplemented 914067d14a6a27b59bba1c53cc18cb67eb9811fc (hinted by @cfeck), plus a refactoring of TerminalDisplay::findWordStart()

findWordStart() had bounds check issues and an off-by-one for the case when the acquired region was more than two screens down.

TerminalDisplay::findWordEnd() is very similarly implemented, but I haven't found a case where it fails, so I haven't touched it.

Since 914067d14a6a27b59bba1c53cc18cb67eb9811fc caused a revert, I've tested the changes thoroughly (the cases are in the Test Plan below).

Test Plan:
Corner cases tested (everything was run under valgrind, since I had no crashes without it pre - f98c752bce9fa11f1e81cf6ef8c02b3c3861c341):

- At the end of the word, current Konsole doesn't select "@" at the end of the word when double-clicking, but selects it when the mouse is moved. With the introduced changes the behavior is to consistently ignore the last "@" character.
- When 10K lines buffer is underfilled, dragged doubleclick+scrolled up by dragging the mouse above the terminal (this generates valgrind warnings on 5a31b4af6ddaba36866d092cb169faec3ca2cef1 that might have caused Konsole to crash)
- Same with overfilled 10K lines buffer.
- With decreased window size and some chars hidden, dblclick and drag up and down to the end of the buffer. The ends of the string are trimmed (like in current console), the rest of the string is properly selected.
- With increased window size and padded chars, prod the buffer limits. Long lines are broken into separate lines -- no difference vs current Konsole.

Reviewers: #konsole, hindenburg, cfeck

Reviewed By: #konsole, hindenburg

Subscribers: ngraham, cfeck, konsole-devel

Tags: #konsole

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

M  +52   -99   src/TerminalDisplay.cpp