From f07c4a91dc65a9a72afc4ac83a352f831b418e65 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 8 Nov 2016 08:32:19 +0530 Subject: [PATCH] Edit Book: Fix an error in the spell checker when trying to replace words with nothing (i.e. deleting words) --- src/calibre/gui2/tweak_book/spell.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/tweak_book/spell.py b/src/calibre/gui2/tweak_book/spell.py index 66f86e0fd9..2cfa86e042 100644 --- a/src/calibre/gui2/tweak_book/spell.py +++ b/src/calibre/gui2/tweak_book/spell.py @@ -758,7 +758,10 @@ class WordsModel(QAbstractTableModel): 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] + try: + new_word = split_into_words(new_word)[0] + except IndexError: + new_word = '' for location in self.words[w]: location.replace(new_word) if w[0] == new_word: