From 649be15d3a70f72c3ab4fb64cd84b7d9b5d847f1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 30 Sep 2014 17:23:38 +0530 Subject: [PATCH] Fix #1370294 [Spell check returns 2 words to misspelled list if separated even if they aren't misspelled anymore](https://bugs.launchpad.net/calibre/+bug/1370294) --- src/calibre/gui2/tweak_book/spell.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/calibre/gui2/tweak_book/spell.py b/src/calibre/gui2/tweak_book/spell.py index 31f3dac955..e3a0258d54 100644 --- a/src/calibre/gui2/tweak_book/spell.py +++ b/src/calibre/gui2/tweak_book/spell.py @@ -32,6 +32,7 @@ from calibre.spell.dictionary import ( builtin_dictionaries, custom_dictionaries, best_locale_for_language, get_dictionary, dprefs, remove_dictionary, rename_dictionary) from calibre.spell.import_from import import_from_oxt +from calibre.spell.break_iterator import split_into_words from calibre.utils.localization import calibre_langcode_to_name, get_language, get_lang, canonicalize_lang from calibre.utils.icu import sort_key, primary_sort_key, primary_contains, contains @@ -748,6 +749,9 @@ class WordsModel(QAbstractTableModel): self.update_word(w) def replace_word(self, w, new_word): + # Hack to deal with replacement words that are actually multiple words, + # ignore all words except the first + new_word = split_into_words(new_word)[0] for location in self.words[w]: location.replace(new_word) if w[0] == new_word: