windingwind / zotero-pdf-preview

Preview Zotero attachments in the library view.
GNU General Public License v3.0
1.17k stars 19 forks source link

Shortcut "p" to open or close the PDF preview freezes Zotero the first time after opening #19

Closed mjthoraval closed 9 months ago

mjthoraval commented 2 years ago

I have seen today that pressing "p" on the keyboard opens or closes the PDF preview at the bottom of the Info pane. This is really nice. Was it added in the last update or did I miss it before? I also could not find it in the documentation. This is an important feature that should be emphasized I think.

I have just noticed a small issue. The first time I press "p" after opening Zotero, Zotero freezes for several seconds. It then recovers, and further pressing "p" does not freeze Zotero anymore. Any idea what is causing this freezing of Zotero? Anyone can reproduce?

Using:

windingwind commented 2 years ago

Sorry I forgot to add the shortcut in the readme. I’m too busy these days. Thanks for pointing out!

I’ll add it to the documentation. Pull requests for documentation is very welcomed.

As for the freeze, I’ll try to reproduce it and see what’s going on. Thanks again!

windingwind commented 2 years ago

The shortcut is added in a previous version. I mentioned it in the forums discussion once. (and it’s missing in the doc)

windingwind commented 2 years ago

added to readme.

mjthoraval commented 2 years ago

Thank you very much! The shortcut is really awesome. I don't use it much on a large screen at the office, but is very handy on my smaller screen at home, where the PDF preview covers some part of the metadata in the Info pane.

For the freeze issue, I have also reported some more serious (related?) crash to another plugin: https://github.com/whacked/zotero-special-tags-column/issues/7 It seems that pressing P triggers something in Zotero even without any plugin. So it is not really related to your plugin. But it affects a bit the use of the shortcut, so it could be useful to dig out the origin of the freeze. It is nothing really serious, so no hurry. Just reporting to let you know about it.

mjthoraval commented 2 years ago

I have tried removing all plugins and explore what happens when pressing P. I have found that when you sort by a column containing text (like Title for example), typing text will jump to the location in the list of items with title starting with these letters. It seems to be referred to as "find-as-you-type" in this post: https://forums.zotero.org/discussion/96770/only-first-typed-letter-recognized-with-find-as-you-type But the same name seems to be used with a different meaning in the documentation (as far as I understand): https://www.zotero.org/support/searching I don't know if there is anything clear about this feature in the documentation?

I guess the short freeze is probably related to this functionality, as suggested by previous discussions on the topic in the forums, due to Zotero constantly listening to keyboard entries to navigate in the item pane. My first testing was by sorting on the Date Modified, so in that case pressing keyboard letter did not jump in the list of items.

This means that any letter keyboard shortcut will not work properly as a shortcut for the preview, as it will break an existing feature of Zotero. At the same time, a shortcut with a combination of keys is much less useful, as it would take too long for something that should be very fast. The Space Bar is already used by Zotero to unselect all items from the item pane, and therefore show the number of items in a collection. The main candidate key I would see to use as a shortcut for the PDF Viewer would be the key near the top left of the keyboard, above Tab and below Escape. But the mapping of this key is keyboard dependent, so you would probably need to make the shortcut a user choice from the Preferences. Any other suggestion or workaround?

windingwind commented 2 years ago

The available shortcuts is very limited in Zotero. Most of them are taken by Zotero itself.

For me, the freeze is not perceptible(or it doesn't exists? not sure). The find-as-you-type seems only triggered when no item is selected(and at that time, you will not press 'P' to preview?) So I guess it doesn't matter maybe.

In my another plugin(PDF Translate), I set key 'T' to switch between the origin title and the translation. Seems it has been working well for a long time.

If the freeze really affects you, I'll try to add an optional shortcut. The shortcut confliction between Zotero and other plugins is terrifying, so maybe leaving more shortcuts untouched would be nice(incase oneday we may need them)

mjthoraval commented 2 years ago

To clarify: the freeze is not related to your plugin. So adding an optional shortcut would not solve this issue. I have reported in the Zotero Forum to see if they can fix the problem: https://forums.zotero.org/discussion/99805/zotero-freezing-when-typing-letters-in-the-main-pane

However, the interference of the shortcut with the "find-as-you-type" feature of Zotero is a real problem. And the optional shortcut would solve it. Illustration of the problem: Screen recording

Steps to reproduce: 1) Sort the main library by "Title" 2) Select an item in the library 3) Press P: The PDF Preview opens but also simultaneously the selection jumps to the first item with title starting with P 4) Press again P: The PDF Preview closes and the selection also jumps to the next item

windingwind commented 2 years ago

Thanks for the detailed instruction!

I'll keep this issue open. However, I’m not sure what we can do before we get more information from the Zotero team.

There will be a big update to Zotero in months. Maybe we could expect it to be more flexible, or at least we could disable it in the future.