Closed ghost closed 6 years ago
+1
Thanks for this report; I thought the shortcut was broken.
This error happened with v4.7.14 (the one that's currently on Ankiweb). In v4.8.0 (the one on Github), using a quick key with no text selected is forbidden so the error doesn't happen anymore. But since I make regular use of this, I've made it possible again and fixed the issue in my fork (here).
Are you saying the behaviour in v4.8.0 is not desirable?
I think it is better to allow the creation of cards with no text selected (I'm using this feature perhaps once every 10 extractions), after a warning ('No text was selected. Continue?'): here is the commit. It is a bit dangerous when "Edit extracted note" isn't checked, though, as empty cards can be created.
It can be useful to use a shortcut to create a basic note, or a cloze deletion note, without selecting any text. For example, if the user wants to reformulate the sentence(s).
However a bug sometimes happens when I try to do that. It specifically happens when I use a shortcut after having used another (or the same) shortcut, without clicking on the text between both. It never happens when I simple-click on the text between shortcut uses. The bug also happens when I select a piece of text, then click once on the text, then use the shortcut. And when I use a shortcut having never clicked on the text before.
With a shortcut creating a Basic note, pasting text to Front field (these settings):
2 error windows are opened:
Error ... Debug info: Anki 2.1.0beta27 Python 3.6.2 Qt 5.9.2 PyQt 5.9 Platform: Linux Flags: frz=True ao=True
Caught exception: File "/home/.../.local/share/Anki2/addons21/1081195335/main.py", line 169, in createNote addCards.editor.setNote(newNote) File "aqt/editor.py", line 289, in setNote File "aqt/editor.py", line 304, in loadNote File "anki/media.py", line 251, in escapeImages File "/home/dae/Local/py59/lib/python3.6/re.py", line 191, in sub <class 'TypeError'>: expected string or bytes-like object
Then:
Error ... Debug info: Anki 2.1.0beta27 Python 3.6.2 Qt 5.9.2 PyQt 5.9 Platform: Linux Flags: frz=True ao=True
Caught exception: File "aqt/editor.py", line 312, in oncallback File "aqt/editor.py", line 340, in checkValid File "anki/notes.py", line 136, in dupeOrEmpty <class 'AttributeError'>: 'NoneType' object has no attribute 'strip' Caught exception: File "aqt/editor.py", line 312, in oncallback File "aqt/editor.py", line 340, in checkValid File "anki/notes.py", line 136, in dupeOrEmpty <class 'AttributeError'>: 'NoneType' object has no attribute 'strip'
With a shortcut creating a Basic note, pasting text to Back field (these settings):
Only the first error window appears.
And with a shortcut creating a Cloze Deletion note, pasting text to Text field (these settings):
Both errors happen.
Then in each case I find myself in front of an empty IR3 note, instead of an empty Basic or Cloze Deletion note: