diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 3ccb524deb..af6158881d 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -3170,6 +3170,10 @@ bool Paragraph::spellCheck(pos_type & from, pos_type & to, WordLangTuple & wl, return false; docstring word = asString(from, to, AS_STR_INSETS); + // Ignore words with digits + // FIXME: make this customizable + // (note that hunspell ignores words with digits by default) + bool const ignored = hasDigit(word); Language * lang = const_cast(getFontSettings( d->inset_owner_->buffer().params(), from).language()); if (lang == d->inset_owner_->buffer().params().language @@ -3181,7 +3185,8 @@ bool Paragraph::spellCheck(pos_type & from, pos_type & to, WordLangTuple & wl, lang->setVariety(lang_variety); } wl = WordLangTuple(word, lang); - SpellChecker::Result res = speller->check(wl); + SpellChecker::Result res = ignored ? + SpellChecker::OK : speller->check(wl); #if 0 // FIXME: the code below makes aspell abort if a word in an unknown // language is checked. diff --git a/src/support/lstrings.cpp b/src/support/lstrings.cpp index fef11cf1d4..f5f3b1c476 100644 --- a/src/support/lstrings.cpp +++ b/src/support/lstrings.cpp @@ -315,6 +315,26 @@ bool isStrDbl(string const & str) } +bool hasDigit(docstring const & str) +{ + if (str.empty()) + return false; + + // Remove leading and trailing white space chars. + docstring const tmpstr = trim(str); + if (tmpstr.empty()) + return false; + + docstring::const_iterator cit = tmpstr.begin(); + docstring::const_iterator end = tmpstr.end(); + for (; cit != end; ++cit) + if (isdigit((*cit))) + return true; + + return false; +} + + static bool isHexChar(char_type c) { return c == '0' || diff --git a/src/support/lstrings.h b/src/support/lstrings.h index 7b4751b020..3bd30e8a77 100644 --- a/src/support/lstrings.h +++ b/src/support/lstrings.h @@ -44,6 +44,9 @@ bool isStrUnsignedInt(std::string const & str); /// bool isStrDbl(std::string const & str); +/// does the string contain a digit? +bool hasDigit(docstring const & str); + bool isHex(docstring const & str); int hexToInt(docstring const & str);