Bug 192922 - Klipper should ignore blank entries
Summary: Klipper should ignore blank entries
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Clipboard widget & pop-up (show other bugs)
Version: 5.15.3
Platform: unspecified Linux
: NOR wishlist
Target Milestone: 1.0
Assignee: Esben Mose Hansen
URL:
Keywords:
: 126446 220544 316651 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-05-16 19:55 UTC by Michal Ziabkowski
Modified: 2023-08-14 19:54 UTC (History)
10 users (show)

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


Attachments
This patch fixes bug #192922 (1.06 KB, patch)
2015-02-08 02:37 UTC, Patrick Eigensatz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Ziabkowski 2009-05-16 19:55:58 UTC
Version:           v0.9.7 (using 4.2.85 (KDE 4.2.85 (KDE 4.3 Beta1)), Gentoo)
Compiler:          i686-pc-linux-gnu-gcc
OS:                Linux (i686) release 2.6.29-gentoo-r4

From time to time blank entries appear in Klipper. While I'm not sure when it happens, I'd like to suggest that any blank entries be ignored. Keeping them on the list is simply wasteful.
Comment 1 Esben Mose Hansen 2009-05-17 10:10:39 UTC
It happens when you select or copy one or more spaces/tabs/newlines. Getting rid of them is tempting, but as a lot of people actually do copy and paste whitespace around, doing so will have to be configurable. In fact, perhaps the best option would be "ignore whitespace differences in history", which would also make all blanks the same & empty.
Comment 2 Christoph Feck 2010-01-13 02:52:22 UTC
*** Bug 220544 has been marked as a duplicate of this bug. ***
Comment 3 Jekyll Wu 2011-11-09 18:29:19 UTC
*** Bug 126446 has been marked as a duplicate of this bug. ***
Comment 4 Marc MAURICE 2013-03-08 12:48:20 UTC
Any news on that ?
This bug is very annoying. I never had this problem with glipper when I was using  Gnome.

It happen for example when you double click on an empty line, in many programs.
Comment 5 Jekyll Wu 2013-03-16 07:56:24 UTC
*** Bug 316651 has been marked as a duplicate of this bug. ***
Comment 6 Marc MAURICE 2013-03-16 12:51:49 UTC
I just realized that there is an option in klipper preferences : "Prevent empty clipboard"

As stated in Klipper doc : "If selected, the clipboard will never be empty: Klipper will insert the most recent item from the clipboard history into the clipboard instead of allowing it to be empty."

However this is enabled and not working.

Or am I misunderstanding the purpose of this option?
Comment 7 Richard Neill 2013-03-16 13:37:06 UTC
I think what klipper is offering to ignore is the empty string, "",  whereas we're often thinking of a blank line  as a line containing only whitespace.

Perhaps I might suggest a heuristic: 
* When programmers copy around whitespace, it usually has some degree of complexity.
* When one accidentally selects whitespace, it's usually trivial, typically either "space" or "newline" or "space+newline". 

So how about considering 3-or-fewer whitespace characters (i.e. '\s{1,3}' as empty/accidental/unwanted, while including longer entries.
Comment 8 Richard Neill 2013-09-04 23:07:12 UTC
It's also very easy to have a completely empty selection (not just whitespace, but the empty string). It would be really useful if the "prevent empty clipboard" functionality could extend to "prevent empty selection".

To reproduce the problem:

1. Select some text you want to copy
2. Left click in the window where you want to paste. 
3. Accidentally drag the mouse up-and down or left-and-right, causing text (maybe as little as a single space character) to be quickly added to and removed-from the selection.
4. The selection is now inadvertently empty, and middle-clicking to paste it has no effect.
Comment 9 Sudhir Khanger 2014-08-01 18:34:05 UTC
This issue should definitely be resolved. Copy-Pasting is one of the most basic thing that I use throughout the day. I am not sure how Klipper has been picking up white spaces as I never copy them intentionally. An option to not to copy white spaces would be very helpful.
Comment 10 Sudhir Khanger 2014-09-10 14:28:12 UTC
I would like to add another comment that this bug has become painfully clear in Plasma 5. Now instead of no empty lines it has at least 2-3 empty blank lines. I sincerely hope we could address this issue with a priority.
Comment 11 Patrick Eigensatz 2015-02-08 02:37:02 UTC
Created attachment 90972 [details]
This patch fixes bug #192922

This should fix Bug #192922
Comment 12 Patrick Eigensatz 2015-02-08 02:38:57 UTC
My patch fixes Bug #192922. QString::trimmed() is used to check
if the string only consists of whitespace characters. If it does,
the creation of the HistoryStringItem fails.
Comment 13 Nate Graham 2021-08-07 20:10:09 UTC
That patch would prevent people from copying whitspace characters like tabs, spaces, newlines, etc.
Comment 14 Pedro V 2023-08-12 15:36:50 UTC
Isn't this "fixed" already? Klipper seems to ignore more than just blank entries at this point, can be checked easily with:
wl-copy ""
Comment 15 Nate Graham 2023-08-14 19:54:48 UTC
Indeed.