Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

difference between selecting and double clicking words #102

Open
SwissalpS opened this issue Sep 19, 2022 · 8 comments
Open

difference between selecting and double clicking words #102

SwissalpS opened this issue Sep 19, 2022 · 8 comments
Labels
bug Something isn't working

Comments

@SwissalpS
Copy link
Contributor

Describe the bug

There seems to be a difference how snippets are selected.
I noticed weird changes when pruning my history. When deleting an item, the list seemed to update weirdly. The entries didn't just move up. Sometimes an old already removed entry showed up near the top again. It almost felt like the list was being shuffled.

Note: I have been hacking about for #100, so I wasn't alarmed. But now I have the newest version installed by gnome, re-populated history and restarted gnome session.

How To Reproduce

Versions

GNOME Shell 42.4
GCH org.gnome.shell.extensions.clipboard-history cache-only-favorites false
org.gnome.shell.extensions.clipboard-history cache-size 100
org.gnome.shell.extensions.clipboard-history clear-history @as []
org.gnome.shell.extensions.clipboard-history confirm-clear true
org.gnome.shell.extensions.clipboard-history disable-down-arrow true
org.gnome.shell.extensions.clipboard-history display-mode 2
org.gnome.shell.extensions.clipboard-history enable-keybindings false
org.gnome.shell.extensions.clipboard-history history-size 1000
org.gnome.shell.extensions.clipboard-history move-item-first true
org.gnome.shell.extensions.clipboard-history next-entry @as []
org.gnome.shell.extensions.clipboard-history notify-on-copy false
org.gnome.shell.extensions.clipboard-history paste-on-selection false
org.gnome.shell.extensions.clipboard-history prev-entry @as []
org.gnome.shell.extensions.clipboard-history private-mode false
org.gnome.shell.extensions.clipboard-history process-primary-selection true
org.gnome.shell.extensions.clipboard-history strip-text false
org.gnome.shell.extensions.clipboard-history toggle-menu ['<Super><Shift>V']
org.gnome.shell.extensions.clipboard-history toggle-private-mode ['<Super><Shift>P']
org.gnome.shell.extensions.clipboard-history topbar-preview-size 10
org.gnome.shell.extensions.clipboard-history window-width-percentage 33

Steps to reproduce

  1. turn on process-primary-selection
  2. use something like this sample text:
1abcd
2abcd
3abcd
4abcd
5abcd
6abcd
7abcd
  1. double click on each word in order from top to bottom.

  2. open extension's menu and look at list, looks fine.

  3. put mouse over topmost entry's delete button.

  4. click away all seven entries

  5. repeat steps 3 to 6 (or not, up to you)

  6. select some unrelated text to get some new entries unrelated to our test

  7. this time don't double click, instead select by dragging mouse, each word in order.

  8. open extension's menu and look at list, also looks fine.

  9. repeat steps 5 and 6

  10. repeat steps 10 and 11

  11. it will look fine if you always draged from left to right. Otherwise you'll only have the entries where you did from ltr or the last one if you did all from rtl.

Another test would be to select using keyboard, I didn't get around to doing that.

Additional context (if a crash, provide stack trace)

no crash

@SwissalpS SwissalpS added the bug Something isn't working label Sep 19, 2022
@SUPERCILEX
Copy link
Owner

Is there any chance I can see a screen recording of this?

@SwissalpS
Copy link
Contributor Author

I've updated to the newest version and can't exactly reproduce what I described above.
Instead some other weirdness showed up: watch the line of stars.
As soon as I do the first click to double click the next word, the line of stars is put on top of the list.
Peek 24-09-2022 14-34.webm

@SUPERCILEX
Copy link
Owner

Does this still happen if you reboot (or just restart gnome)? I would love to see the database file if you're willing to share. If not, I could give you a patch to apply that has a bunch of debug logging.

@SwissalpS
Copy link
Contributor Author

Does this still happen if you reboot (or just restart gnome)?

Yes, after reboot same reaction. (both these screen recordings were made with gnome under X not wayland)
First click or click to select, changes the first entry to one that was previously selected.
Peek 25-09-2022 21-17.webm

I'd prefer to do the patch route over the database dump. I might learn something in the
process :D

@SUPERCILEX
Copy link
Owner

I'd prefer to do the patch route

Sounds good, here you go. Several things are broken in your latest video: the --- item shouldn't stay at the top since you're copying new items and then at the end the ordering is very messed up. In general, some data structure must be very broken. Right now I'm just trying to find where things go wonky in the logs. In theory we should see Adding entry but not Rewrote menu item after you've deleted stuff.

Subject: [PATCH] Debug logs
---
Index: extension.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/extension.js b/extension.js
--- a/extension.js	(revision 5aba9adb60f22124d2d42b9bd10eee04f8dc8377)
+++ b/extension.js	(date 1664324039960)
@@ -347,11 +347,13 @@
   }
 
   _addEntry(entry, selectEntry, updateClipboard, insertIndex) {
+    log(Me.uuid, "Adding entry", JSON.stringify(entry, ["id", "diskId", "type", "text", "favorite"]), selectEntry, updateClipboard, insertIndex, this.activeHistoryMenuItems);
     if (!entry.favorite && this.activeHistoryMenuItems >= PAGE_SIZE) {
       const items = this.historySection._getMenuItems();
       const item = items[items.length - 1];
       this._rewriteMenuItem(item, entry);
       this.historySection.moveMenuItem(item, 0);
+      log(Me.uuid, "Rewrote menu item")
 
       if (selectEntry) {
         this._selectEntry(entry, updateClipboard);
@@ -539,6 +541,7 @@
   }
 
   _removeEntry(entry, fullyDelete) {
+    log(Me.uuid, "Deleting entry", JSON.stringify(entry, ["id", "diskId", "type", "text", "favorite"]), fullyDelete);
     if (fullyDelete) {
       entry.detach();
 
@@ -572,6 +575,7 @@
   }
 
   _selectEntry(entry, updateClipboard, triggerPaste) {
+    log(Me.uuid, "Selecting entry", JSON.stringify(entry, ["id", "diskId", "type", "text", "favorite"]), updateClipboard, triggerPaste);
     this.currentlySelectedEntry?.menuItem?.setOrnament(PopupMenu.Ornament.NONE);
     this.currentlySelectedEntry = entry;
 
@@ -842,6 +846,7 @@
   }
 
   _processClipboardContent(text) {
+    log(Me.uuid, "_processClipboardContent", this._debouncing, `text=${text}`);
     if (this._debouncing > 0) {
       this._debouncing--;
       return;
@@ -860,6 +865,7 @@
     if (entry) {
       const isFirst =
         entry === this.entries.last() || entry === this.favoriteEntries.last();
+      log(Me.uuid, "Entry found", JSON.stringify(entry, ["id", "diskId", "type", "text", "favorite"]), isFirst, JSON.stringify(this.currentlySelectedEntry, ["id", "diskId", "type", "text", "favorite"]))
       if (!isFirst) {
         this._moveEntryFirst(entry);
       }
@@ -876,6 +882,7 @@
       this.entries.append(entry);
       this._addEntry(entry, true, false, 0);
 
+      log(Me.uuid, "Created new entry", JSON.stringify(entry, ["id", "diskId", "type", "text", "favorite"]))
       if (!CACHE_ONLY_FAVORITES) {
         Store.storeTextEntry(text);
       }

To get the logs, apply the patch (git apply file.patch), restart gnome, run journalctl -f /usr/bin/gnome-shell, and then do the repro.

@SwissalpS
Copy link
Contributor Author

I've moved to another country, sorry for the long wait. Will test this out as soon as I can.

@SwissalpS
Copy link
Contributor Author

Peek 15-10-2022 16-05.webm
gnomepasteDebugA.txt

I should probably try on a new user account to see if it works OK there. Maybe I messed something up when hacking around.

@SUPERCILEX
Copy link
Owner

Thanks for this!

Maybe I messed something up when hacking around.

Yeah, can you try resetting stuff? And are you sure you don't have another program messing around with the clipboard? The logs are just nonsense: they basically show that every time you copy something, the ----s also get copied somehow. This could somehow be the extension's fault if it tells the system to copy the ----s, but I can't figure out the code path where that happens.

I'll also try using the primary clipboard. I usually keep that option off, but I'll turn it on for the next few days to see if I can get weirdness on my end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants