Arthur-Milchior / anki-enhanced-cloze

GNU General Public License v3.0
2 stars 1 forks source link

Conflict with Numeric Keypad Remapping #15

Closed ghost closed 4 years ago

ghost commented 5 years ago

Addon seems to interfere with the "show answer using numerical keys" function of Numeric Keypad Remapping throwing the following error

Error An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed. If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem. When you've discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site. Debug info: Anki 2.1.15 (442df9d6) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3 Platform: Windows 10 Flags: frz=True ao=True sv=2

Caught exception: File "C:\Users\John Smith\AppData\Roaming\Anki2\addons21\653807651__init.py", line 118, in answerCaller return onAnswerButton(int(closureKey)) File "C:\Users\John Smith\AppData\Roaming\Anki2\addons21\653807651\init__.py", line 90, in onAnswerButton self.mw.reviewer._showAnswer() File "", line 2, in _showAnswer File "anki\hooks.py", line 74, in decorator_wrapper File "anki\hooks.py", line 71, in repl File "C:\Users\John Smith\AppData\Roaming\Anki2\addons21\1374772155\main.py", line 233, in onShowAnswer return _old(self) File "aqt\reviewer.py", line 217, in _showAnswer File "aqt\reviewer.py", line 156, in _mungeQA File "aqt\reviewer.py", line 306, in typeAnsFilter File "aqt\reviewer.py", line 367, in typeAnsAnswerFilter File "aqt\reviewer.py", line 431, in correct File "aqt\reviewer.py", line 400, in tokenizeComparison <class 'TypeError'>: normalize() argument 2 must be str, not None

ijgnd commented 4 years ago

the output you posted doesn't mention "enhanced cloze" - instead it refers to the addon with the id "1374772155" which is Image Occlusion Enhanced for Anki 2.1 (alpha).

Disable all add-ons apart from "Numeric Keypad" and "Enhanced Cloze". Then restart. Does the problem persist? If not, the problem is with other add-ons.

ghost commented 4 years ago

@ijgnd Sorry for the late response. Threw the following with all other addons disabled. Anki 2.1.17 (81bdd860) Python 3.8.0 Qt 5.14.0 PyQt 5.13.2 Platform: Windows 10 Flags: frz=True ao=True sv=2

Caught exception: Traceback (most recent call last): File "C:\Users\John Smith\AppData\Roaming\Anki2\addons21\653807651__init.py", line 118, in answerCaller return onAnswerButton(int(closureKey)) File "C:\Users\John Smith\AppData\Roaming\Anki2\addons21\653807651\init__.py", line 90, in onAnswerButton self.mw.reviewer._showAnswer() File "aqt\reviewer.py", line 217, in _showAnswer File "aqt\reviewer.py", line 156, in _mungeQA File "aqt\reviewer.py", line 306, in typeAnsFilter File "aqt\reviewer.py", line 367, in typeAnsAnswerFilter File "aqt\reviewer.py", line 431, in correct File "aqt\reviewer.py", line 400, in tokenizeComparison TypeError: normalize() argument 2 must be str, not None

ijgnd commented 4 years ago

It's been a long time. As far as I remember "Enhanced Cloze" doesn't affect the reviewer.

Does the problem occur if you disable "Enhanced Cloze" (and all other add-ons) and only use "Numeric Keypad"? If so you should report this to the creator of the "Numeric Keypad" add-on.

If this disappears: Enable all your other add-ons except for "Enhanced Cloze". So use "numceric keypad" with "Image Occlusion". If the problem persists you should report this to the creator of the "Numeric Keypad" add-on.

If the problem only occurs when "Enhanced Cloze" is enabled: Does it always occur or just for some cards from certain note types? If so it would help if you could offer more details and share an note that creates this problem. In this case maybe also ask the creator of the "Numeric Keypad" add-on who knows a lot about Anki.

ghost commented 4 years ago

In order 1: No 2: Problem disappears 3: Problem only occurs with an Enhanced Cloze card type as demonstrated in this gif 2019-12-16_23-06-01 To add context, I'm pressing the 3 button repeatedly.

ijgnd commented 4 years ago

should be this: the problem is in "numeric keypad" and has nothing to do with "enhanced cloze".

Make a new profile, then add a "Basic (type in the answer)" note and review the card created from it. Don't type anything into the text field, just press "3". Then I get your error.

The error should disappear if if you change line 90 in "numeric keypad" from self.mw.reviewer._showAnswer() to self.mw.reviewer._getTypedAnswer() -the latter seems to be what the reviewer calls, see https://github.com/dae/anki/blob/master/aqt/reviewer.py#L277 and https://github.com/dae/anki/blob/master/aqt/reviewer.py#L291.

When you use the default "numeric keypad" this crucial line is not evaluated: https://github.com/dae/anki/blob/master/aqt/reviewer.py#L473

Can you reproduce the "numeric keypad" bug without other add-ons and does my fix has any side effects?

ghost commented 4 years ago

It works! I could reproduce the bug and your fix does not appear to have any side effects as far as I can see. Thank you so much for your time.