mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-02 20:12:24 +12:00
Merge pull request #1214 from TheShadowblast123/develop
Update spellchecker.py And Fixed crashing
This commit is contained in:
commit
3d4eef2b49
|
@ -187,6 +187,7 @@ class BasicDictionary:
|
|||
def checkText(self, text):
|
||||
# Based on http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check/
|
||||
WORDS = r'(?iu)((?:[^_\W]|\')+)[^A-Za-z0-9\']'
|
||||
|
||||
# (?iu) means case insensitive and Unicode
|
||||
# ((?:[^_\W]|\')+) means words exclude underscores but include apostrophes
|
||||
# [^A-Za-z0-9\'] used with above hack to prevent spellcheck while typing word
|
||||
|
@ -197,8 +198,27 @@ class BasicDictionary:
|
|||
|
||||
for word_object in re.finditer(WORDS, text):
|
||||
word = word_object.group(1)
|
||||
mispelled = self.isMisspelled(word)
|
||||
if mispelled == False:
|
||||
continue
|
||||
#inorder to prevent apostrophes causing false positives and keep the same functionality otherwise,
|
||||
#check that the word doesn't have any additional punctuation on it.
|
||||
if re.match("^[^\w]|([\p{P}'])$", word):
|
||||
|
||||
# ^[^\w] checks that it doesn't start with a word character
|
||||
# ([\p{P}'])$ checks it doesn't end with punctuation characters
|
||||
|
||||
apostrophe_WORDS = r'(?iu)\b(?<=[\s\'"(])((?:[a-zA-Z]|\')+)(?=\b)'
|
||||
|
||||
# \b(?<=[\s\'"(]) looks for nonword characters and starts grouping after
|
||||
# (?=\b) looks for the word boundary
|
||||
# ((?:[a-zA-Z]|\')+) greedily matches for letters and apostrophes
|
||||
|
||||
temp = re.match(apostrophe_WORDS, word)
|
||||
mispelled = self.isMisspelled(temp.group(1))
|
||||
|
||||
if (mispelled and not self.isCustomWord(word)):
|
||||
|
||||
if (self.isMisspelled(word) and not self.isCustomWord(word)):
|
||||
matches.append(BasicMatch(
|
||||
word_object.start(1), word_object.end(1)
|
||||
))
|
||||
|
|
|
@ -384,7 +384,12 @@ class corkDelegate(QStyledItemDelegate):
|
|||
|
||||
# Draw Summary
|
||||
# One line
|
||||
if lineSummary:
|
||||
#checking that textColor is actually defined before we use it
|
||||
try:
|
||||
textColor
|
||||
except:
|
||||
textColor = None
|
||||
if lineSummary and textColor:
|
||||
p.save()
|
||||
f = QFont(option.font)
|
||||
f.setBold(True)
|
||||
|
@ -396,7 +401,7 @@ class corkDelegate(QStyledItemDelegate):
|
|||
p.restore()
|
||||
|
||||
# Full summary
|
||||
if fullSummary:
|
||||
if fullSummary and textColor:
|
||||
p.save()
|
||||
p.setFont(option.font)
|
||||
p.setPen(textColor)
|
||||
|
|
Loading…
Reference in a new issue