Bug 1047 update - defaults and edge case

Handles edge case where it was possible to highlight adjacent
sub-terms without whitespace between them.

Also makes ignoring words not prefixed by whitespace the
assumed behaviour.
This commit is contained in:
Fil Krynicki 2014-05-10 17:47:21 -04:00
parent 9095a45ba7
commit eb5ef270ba
3 changed files with 8 additions and 8 deletions

View File

@ -163,7 +163,7 @@ namespace MWGui
std::string::const_iterator i = text.begin (); std::string::const_iterator i = text.begin ();
KeywordSearchT::Match match; KeywordSearchT::Match match;
while (i != text.end () && keywordSearch->search (i, text.end (), match, false)) while (i != text.end () && keywordSearch->search (i, text.end (), match, text.begin ()))
{ {
if (i != match.mBeg) if (i != match.mBeg)
addTopicLink (typesetter, 0, i - text.begin (), match.mBeg - text.begin ()); addTopicLink (typesetter, 0, i - text.begin (), match.mBeg - text.begin ());

View File

@ -178,7 +178,7 @@ struct JournalViewModelImpl : JournalViewModel
KeywordSearchT::Match match; KeywordSearchT::Match match;
while (i != utf8text.end () && mModel->mKeywordSearch.search (i, utf8text.end (), match)) while (i != utf8text.end () && mModel->mKeywordSearch.search (i, utf8text.end (), match, utf8text.begin()))
{ {
if (i != match.mBeg) if (i != match.mBeg)
visitor (0, i - utf8text.begin (), match.mBeg - utf8text.begin ()); visitor (0, i - utf8text.begin (), match.mBeg - utf8text.begin ());

View File

@ -66,18 +66,18 @@ public:
return false; return false;
} }
bool search (Point beg, Point end, Match & match, bool matchSubword = true) bool search (Point beg, Point end, Match & match, Point start)
{ {
char prev = ' ';
for (Point i = beg; i != end; ++i) for (Point i = beg; i != end; ++i)
{ {
// check if previous character marked start of new word // check if previous character marked start of new word
if (!matchSubword && isalpha(prev)) if (i != start)
{ {
prev = *i; Point prev = i;
--prev;
if(isalpha(*prev))
continue; continue;
} }
prev = *i;
// check first character // check first character
typename Entry::childen_t::iterator candidate = mRoot.mChildren.find (std::tolower (*i, mLocale)); typename Entry::childen_t::iterator candidate = mRoot.mChildren.find (std::tolower (*i, mLocale));