src/eric7/EricWidgets/EricSpellCheckedTextEdit.py

branch
eric7
changeset 9786
f94b530722af
parent 9719
efa8d4c9cb44
child 10069
435cc5875135
equal deleted inserted replaced
9785:84684a40187d 9786:f94b530722af
268 """ 268 """
269 cursor = self.cursorForPosition(pos) 269 cursor = self.cursorForPosition(pos)
270 misspelledWords = getattr(cursor.block().userData(), "misspelled", []) 270 misspelledWords = getattr(cursor.block().userData(), "misspelled", [])
271 271
272 # If the cursor is within a misspelling, select the word 272 # If the cursor is within a misspelling, select the word
273 for (start, end) in misspelledWords: 273 for start, end in misspelledWords:
274 if start <= cursor.positionInBlock() <= end: 274 if start <= cursor.positionInBlock() <= end:
275 blockPosition = cursor.block().position() 275 blockPosition = cursor.block().position()
276 276
277 cursor.setPosition( 277 cursor.setPosition(
278 blockPosition + start, QTextCursor.MoveMode.MoveAnchor 278 blockPosition + start, QTextCursor.MoveMode.MoveAnchor
548 return 548 return
549 549
550 # Build a list of all misspelled words and highlight them 550 # Build a list of all misspelled words and highlight them
551 misspellings = [] 551 misspellings = []
552 with contextlib.suppress(enchant.errors.Error): 552 with contextlib.suppress(enchant.errors.Error):
553 for (word, pos) in self.__tokenizer(text): 553 for word, pos in self.__tokenizer(text):
554 if not self.__spellDict.check(word): 554 if not self.__spellDict.check(word):
555 self.setFormat(pos, len(word), EnchantHighlighter.ErrorFormat) 555 self.setFormat(pos, len(word), EnchantHighlighter.ErrorFormat)
556 misspellings.append((pos, pos + len(word))) 556 misspellings.append((pos, pos + len(word)))
557 557
558 # Store the list so the context menu can reuse this tokenization 558 # Store the list so the context menu can reuse this tokenization

eric ide

mercurial