Strip non-word characters when adding to user dictionary
This commit is contained in:
@@ -53,6 +53,7 @@ class GuiDocEditor(QTextEdit):
|
||||
self.wordCount = 0
|
||||
self.paraCount = 0
|
||||
self.lastEdit = 0
|
||||
self.nonWord = "\"'"
|
||||
|
||||
# Typography
|
||||
self.typDQOpen = self.mainConf.fmtDoubleQuotes[0]
|
||||
@@ -137,6 +138,11 @@ class GuiDocEditor(QTextEdit):
|
||||
created, and when the user changes the main editor preferences.
|
||||
"""
|
||||
|
||||
# Some Constants
|
||||
self.nonWord = "\"'"
|
||||
self.nonWord += "".join(self.mainConf.fmtDoubleQuotes)
|
||||
self.nonWord += "".join(self.mainConf.fmtSingleQuotes)
|
||||
|
||||
# Reload spell check and dictionaries
|
||||
self._setupSpellChecking()
|
||||
self.setDictionaries()
|
||||
@@ -500,7 +506,7 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
theCursor = self.cursorForPosition(thePos)
|
||||
theCursor.select(QTextCursor.WordUnderCursor)
|
||||
theWord = theCursor.selectedText()
|
||||
theWord = theCursor.selectedText().strip().strip(self.nonWord)
|
||||
if theWord == "":
|
||||
return
|
||||
if self.theDict.checkWord(theWord):
|
||||
@@ -541,7 +547,7 @@ class GuiDocEditor(QTextEdit):
|
||||
return
|
||||
|
||||
def _addWord(self, theCursor):
|
||||
theWord = theCursor.selectedText().strip()
|
||||
theWord = theCursor.selectedText().strip().strip(self.nonWord)
|
||||
logger.debug("Added '%s' to project dictionary" % theWord)
|
||||
self.theDict.addWord(theWord)
|
||||
self.hLight.setDict(self.theDict)
|
||||
|
||||
Reference in New Issue
Block a user