mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-09-21 03:51:26 +12:00
Fixes: Spell checker is active for partial words. #166
This commit is contained in:
parent
eb89d2f309
commit
ee058a309f
1 changed files with 13 additions and 3 deletions
|
@ -80,11 +80,21 @@ class basicHighlighter(QSyntaxHighlighter):
|
|||
fmt)
|
||||
|
||||
# Spell checking
|
||||
|
||||
# Following algorithm would not check words at the end of line.
|
||||
# This hacks adds a space to every line where the text cursor is not
|
||||
# So that it doesn't spellcheck while typing, but still spellchecks at
|
||||
# end of lines. See github's issue #166.
|
||||
textedText = text
|
||||
if self.currentBlock().position() + len(text) != \
|
||||
self.editor.textCursor().position():
|
||||
textedText = text + " "
|
||||
|
||||
# Based on http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check/
|
||||
WORDS = '(?iu)[\w\']+'
|
||||
WORDS = '(?iu)([\w\']+)\W' # (?iu) means case insensitive and unicode
|
||||
if hasattr(self.editor, "spellcheck") and self.editor.spellcheck:
|
||||
for word_object in re.finditer(WORDS, text):
|
||||
if self.editor._dict and not self.editor._dict.check(word_object.group()):
|
||||
for word_object in re.finditer(WORDS, textedText):
|
||||
if self.editor._dict and not self.editor._dict.check(word_object.group(1)):
|
||||
format = self.format(word_object.start())
|
||||
format.setUnderlineColor(self._misspelledColor)
|
||||
# SpellCheckUnderline fails with some fonts
|
||||
|
|
Loading…
Reference in a new issue