Make word match for spell check exclude underscore from words

See issue #283.

Adds (?!_) to perform negative lookahead to exclude "_" from pattern match.

https://stackoverflow.com/questions/14858346/regular-expressions-how-to-express-w-without-underscore
This commit is contained in:
Curtis Gedak 2018-02-15 12:46:22 -07:00
parent 4638ba878f
commit 63b471e10d

View file

@ -146,8 +146,9 @@ class BasicHighlighter(QSyntaxHighlighter):
textedText = text + " "
# Based on http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check/
WORDS = r'(?iu)([\w\']+)[^\'\w]'
# (?iu) means case insensitive and unicode
WORDS = r'(?iu)(((?!_)[\w\'])+)'
# (?iu) means case insensitive and Unicode
# (?!_) means perform negative lookahead to exclude "_" from pattern match. See issue #283
if hasattr(self.editor, "spellcheck") and self.editor.spellcheck:
for word_object in re.finditer(WORDS, textedText):
if (self.editor._dict