Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace underscores with spaces when running spell checker #1417

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions novelwriter/gui/dochighlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,11 @@ def initHighlighter(self):
hReg.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption)
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
# consider to be word separators
wordSep = r"\-_\+/"
wordSep += nwUnicode.U_ENDASH
wordSep += nwUnicode.U_EMDASH
self.spellRx = QRegularExpression(r"\b[^\s"+wordSep+r"]+\b")
uCode = nwUnicode.U_ENDASH + nwUnicode.U_EMDASH
self.spellRx = QRegularExpression(r"\b[^\s\-\+\/" + uCode + r"]+\b")
self.spellRx.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption)

return True
Expand Down Expand Up @@ -389,7 +387,7 @@ def highlightBlock(self, theText):
if not self.spellCheck:
return

rxSpell = self.spellRx.globalMatch(theText, 0)
rxSpell = self.spellRx.globalMatch(theText.replace("_", " "), 0)
while rxSpell.hasNext():
rxMatch = rxSpell.next()
if not self.spEnchant.checkWord(rxMatch.captured(0)):
Expand Down