shigeyukey / Auto-Highlight-Cloze-in-Browser-Fork-by-Shige

🖌️Auto Highlight Cloze in Browser (Fork by Shige)
https://ankiweb.net/shared/info/210078606
Other
0 stars 0 forks source link

Error when selecting an empty deck or note type in the browse #3

Closed shigeyukey closed 3 months ago

shigeyukey commented 3 months ago
Anki 24.06.1 (205068a9)  (ao)
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
Platform: Windows-10-10.0.22631

Traceback (most recent call last):
  File "aqt.webview", line 631, in handler
  File "aqt.editor", line 634, in <lambda>
  File "aqt.utils", line 1211, in <lambda>
  File "aqt.browser.browser", line 565, in on_all_or_selected_rows_changed
  File "_aqt.hooks", line 1004, in __call__
  File "C:\Users\shigg\AppData\Roaming\Anki2\addons21\highlight_search_results\browser.py", line 77, in on_browser_did_change_row
    Highlight cloze deletions in Editor pane on selecting a cloze card
IndexError: list index out of range
shigeyukey commented 3 months ago

If no card is available, return it.

# browser.py
def on_browser_did_change_row(
    browser: Browser, current: Optional[int] = None, previous: Optional[int] = None
):
    """
    Highlight cloze deletions in Editor pane on selecting a cloze card
    """

    selected_cards = browser.selected_cards() # add
    if not selected_cards: # add
        return # add

    card_id = browser.selected_cards()[0]
    card = mw.col.get_card(card_id)
    note = card.note()