Replace underscores with spaces when running spell checker (#1417)
This commit is contained in:
@@ -224,13 +224,11 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
|||||||
hReg.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption)
|
hReg.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption)
|
||||||
self.rxRules.append((hReg, regRules))
|
self.rxRules.append((hReg, regRules))
|
||||||
|
|
||||||
# Build a QRegExp for spell checker
|
# Build a QRegExp for the spell checker
|
||||||
# Include additional characters that the highlighter should
|
# Include additional characters that the highlighter should
|
||||||
# consider to be word separators
|
# consider to be word separators
|
||||||
wordSep = r"\-_\+/"
|
uCode = nwUnicode.U_ENDASH + nwUnicode.U_EMDASH
|
||||||
wordSep += nwUnicode.U_ENDASH
|
self.spellRx = QRegularExpression(r"\b[^\s\-\+\/" + uCode + r"]+\b")
|
||||||
wordSep += nwUnicode.U_EMDASH
|
|
||||||
self.spellRx = QRegularExpression(r"\b[^\s"+wordSep+r"]+\b")
|
|
||||||
self.spellRx.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption)
|
self.spellRx.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -389,7 +387,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
|||||||
if not self.spellCheck:
|
if not self.spellCheck:
|
||||||
return
|
return
|
||||||
|
|
||||||
rxSpell = self.spellRx.globalMatch(theText, 0)
|
rxSpell = self.spellRx.globalMatch(theText.replace("_", " "), 0)
|
||||||
while rxSpell.hasNext():
|
while rxSpell.hasNext():
|
||||||
rxMatch = rxSpell.next()
|
rxMatch = rxSpell.next()
|
||||||
if not self.spEnchant.checkWord(rxMatch.captured(0)):
|
if not self.spEnchant.checkWord(rxMatch.captured(0)):
|
||||||
|
|||||||
Reference in New Issue
Block a user