544 if self.__spellDict is None or self.__tokenizer is None: |
544 if self.__spellDict is None or self.__tokenizer is None: |
545 return |
545 return |
546 |
546 |
547 # Build a list of all misspelled words and highlight them |
547 # Build a list of all misspelled words and highlight them |
548 misspellings = [] |
548 misspellings = [] |
549 for (word, pos) in self.__tokenizer(text): |
549 with contextlib.suppress(enchant.errors.Error): |
550 if not self.__spellDict.check(word): |
550 for (word, pos) in self.__tokenizer(text): |
551 self.setFormat(pos, len(word), EnchantHighlighter.ErrorFormat) |
551 if not self.__spellDict.check(word): |
552 misspellings.append((pos, pos + len(word))) |
552 self.setFormat(pos, len(word), EnchantHighlighter.ErrorFormat) |
|
553 misspellings.append((pos, pos + len(word))) |
553 |
554 |
554 # Store the list so the context menu can reuse this tokenization |
555 # Store the list so the context menu can reuse this tokenization |
555 # pass (Block-relative values so editing other blocks won't |
556 # pass (Block-relative values so editing other blocks won't |
556 # invalidate them) |
557 # invalidate them) |
557 data = QTextBlockUserData() |
558 data = QTextBlockUserData() |