Bug 461794

Summary: selected string sometimes not copied in entirety
Product: [Applications] konsole Reporter: xiota <kde>
Component: copy-pasteAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED FIXED    
Severity: normal CC: adam, agurenko, ninjalj, zawertun
Priority: NOR    
Version: master   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description xiota 2022-11-13 22:48:01 UTC
SUMMARY

Sometimes, when I copy selected text, only the beginning of the text is copied.

STEPS TO REPRODUCE
1. Use `locate` to search for files
2. Select a path
3. Copy with ctrl+shift+c
4. Paste somewhere with ctrl+shift+v or check clipboard manager

OBSERVED RESULT

Most frequently, I have noticed it when copying paths after using `find` or `locate`, but it has occurred with other strings.  When it happens, usually, the file name is incomplete.  Immediately reselecting and recopying results in the same incomplete path being copied.  But recently I noticed, after running a different command and retrying the copy/paste, the entire path copied normally.

The clipboard history shows that incomplete text was previously copied.  No other program has shown this problem, so I doubt it's caused by the clipboard manager.

EXPECTED RESULT

The entire selection should be copied.

SOFTWARE/OS VERSIONS
Linux: 6.0.8
KDE Plasma Version: 5.26.3
KDE Frameworks Version: 5.99.0
Qt Version: 5.15.7

ADDITIONAL INFORMATION

This problem has occurred intermittently for many consecutive versions/builds, possibly going back to Konsole 21.x.  Still occurs with Konsole 22.08.3.  Occurs with new builds of master.

I've been using starship to change the command prompt, but this problem occurred before I started using it.

My profile has unlimited scrolling, "Highlight the lines coming into view", and "Reflow lines when terminal resizes".  I have not tried changing these settings to see if there is any difference.  However, this has happened early in sessions, when there has been little output, with lines that do not wrap, and when the window had not been resized.
Comment 1 xiota 2022-11-16 22:43:10 UTC
> But recently I noticed, after running a different command and retrying the copy/paste, the entire path copied normally.

So that happens only sometimes.  Other times, the clipboard contents does not change, even when I try to select and copy something else.  Copy/paste works again in a new tab.
Comment 2 ninjalj 2022-11-23 23:59:31 UTC
Could this be the same as bug #461542? What are your settings for "Trim trailing spaces" and "Trim leading spaces" (inside Profile settings → "Mouse")? Had the line you were selecting from already moved into the scrollback buffer? Can you reproduce it, and if so, what is the whole content of the line you were selecting from, and the content of the selection-marked part?
Comment 3 xiota 2022-11-24 03:42:58 UTC
(In reply to ninjalj from comment #2)

> Could this be the same as bug #461542?

It seems similar but:

* That one is reported to be fixed by a commit in Oct 2022.  This one still occurs with builds from check outs in Nov 2022.
* That one is described as reproducible.  This one occurs intermittently, with no discernible pattern.  Running the same commands and copying the same strings does not reproduce the problem.

> What are your settings for "Trim trailing spaces" and "Trim leading spaces" (inside Profile settings → "Mouse")?

Trim leading spaces is disabled.  Trim trailing spaces is enabled.  I will try disabling trim trailing spaces.  However, I usually select and copy paths without any leading or trailing spaces by double clicking them.  I suppose lack of a trailing space could trip up trailing space removal if there is an off-by-one error or some such.

> Had the line you were selecting from already moved into the scrollback buffer?

The problem still occurs when the path is visible without scrolling.  However, unlimited scrolling is enabled.  So possibly all output is sent to the "buffer" immediately?

> Can you reproduce it, and if so, what is the whole content of the line you were
selecting from, and the content of the selection-marked part?

It occurs intermittently with no discernible pattern.  Repeating the same commands and steps in new windows and tabs does not reproduce the problem.
Comment 4 xiota 2022-11-24 03:51:19 UTC
> > Committed on 10/11/2022
> That one is reported to be fixed by a commit in Oct 2022.

So, "Committed on 10/11/2022" could be Nov, not Oct?  I'll rebuild and see if there's any difference.
Comment 5 Adam Batkin 2022-12-09 15:47:38 UTC
I have just noticed this with konsole5-22.08.1-1.fc36.x86_64 (Fedora 36).

I have "Copy on select" selected, as well as Trim leading and trailing spaces. But my issue isn't that spaces are being trimmed, my issue is that entire chunks of text are (sometimes) being trimmed.

I can reproduce it, but only intermittently. So far, I have only found it to happen for things that are in the scrollback buffer (i.e. I need to scroll up (at least) a few lines). Interestingly, the same text when highlighted from the scrollback vs from the current screen seems to act differently.

I ran a whois command. One of the lines looks like this:

Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited

If I double-click in the URL from the scrollback buffer, it will highlight the entire URL, but only "http:" will get copied. For the line above which is almost identical, only "https://" will get copied.

When I ran the whois command again, this time I can double-click (on the _new_ output) and it copies the whole URL (note: I didn't need to scrollback to get there). If I scroll up, the old output still copies (consistently) incorrectly.

More interestingly, I hit enter a few times, ran some more commands (to push the "new" output out of view and into the scrollback buffer), and now all of them copy just fine.
Comment 6 xiota 2022-12-09 18:58:14 UTC
I have not had the problem recur with a git checkout from Nov 24, so possibly fixed with bug #461542?  I am now switching to the recently released Konsole 22.12.0.

Unfortunately, the problem occurred intermittently and inconsistently on my computer.  But previously, it usually occurred a few times per week of normal use.  So if it doesn't recur over the next few weeks, I would consider it resolved.
Comment 7 xiota 2022-12-29 04:35:27 UTC
The problem appears to have been fixed.  I have not seen the problem recur with Konsole 22.12.0 during the last two to three weeks.  People on distros running older versions of KDE should ask the maintainers to consider backporting this commit: https://invent.kde.org/utilities/konsole/commit/f01fdd0a55726e60f068e72573d0323129a10eb1