Allow words to be ignored by the spell checker (session only)

This commit is contained in:
Veronica Berglyd Olsen
2024-09-28 11:21:04 +02:00
parent 5ed03e29f3
commit a6494b4226
4 changed files with 48 additions and 43 deletions
+9 -3
View File
@@ -158,15 +158,21 @@ def testCoreSpell_Enchant(monkeypatch, mockGUI, fncPath):
assert isinstance(spChk._enchant, FakeEnchant)
assert spChk.checkWord("word") is True
assert spChk.suggestWords("word") == []
assert spChk.addWord("word") is True
spChk.addWord("word")
assert "word" in spChk._userDict
# Set the dict to None, and check enchant error handling
spChk = NWSpellEnchant(project)
spChk._enchant = None # type: ignore
assert spChk.checkWord("word") is True
assert spChk.suggestWords("word") == []
assert spChk.addWord("word") is False
assert spChk.addWord("\n\t ") is False
spChk.addWord("word")
assert "word" not in spChk._userDict
spChk.addWord("\n\t ")
assert "\n\t " not in spChk._userDict
assert spChk.describeDict() == ("", "")
# Load the proper enchant package (twice)
+5 -1
View File
@@ -453,9 +453,13 @@ def testGuiEditor_SpellChecking(qtbot, monkeypatch, nwGUI, projPath, ipsumText,
ctxMenu = getMenuForPos(docEditor, 16)
assert ctxMenu is not None
actions = [x.text() for x in ctxMenu.actions() if x.text()]
assert "Ignore Word" in actions
assert "Add Word to Dictionary" in actions
assert "Lorax" not in SHARED.spelling._userDict
ctxMenu.actions()[7].trigger()
ctxMenu.actions()[7].trigger() # Ignore
assert "Lorax" not in SHARED.spelling._userDict
ctxMenu.actions()[8].trigger() # Add
assert "Lorax" in SHARED.spelling._userDict
ctxMenu.setObjectName("")
ctxMenu.deleteLater()