From: Jean-Marc Lasgouttes Date: Fri, 16 May 2014 13:17:10 +0000 (+0200) Subject: Do not forget last word of paragraph in completion X-Git-Tag: 2.2.0alpha1~1947 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ee7c4db72a9dd392d7e1e34463c3ae11fce670ee;p=lyx.git Do not forget last word of paragraph in completion With the old code, the last word of a paragraph would not be added in the completion list. The key difference is to pass `from' instead of `pos' to FontList::fontiterator. Slight cleanup of the code. --- diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index b6ca893698..c551ea022c 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -3840,20 +3840,19 @@ void Paragraph::locateWord(pos_type & from, pos_type & to, void Paragraph::collectWords() { - pos_type n = size(); - for (pos_type pos = 0; pos < n; ++pos) { + for (pos_type pos = 0; pos < size(); ++pos) { if (isWordSeparator(pos)) continue; pos_type from = pos; locateWord(from, pos, WHOLE_WORD); - if ((pos - from) >= (int)lyxrc.completion_minlength) { - docstring word = asString(from, pos, AS_STR_NONE); - FontList::const_iterator cit = d->fontlist_.fontIterator(pos); - if (cit == d->fontlist_.end()) - return; - Language const * lang = cit->font().language(); - d->words_[lang->lang()].insert(word); - } + if (pos < from + lyxrc.completion_minlength) + continue; + FontList::const_iterator cit = d->fontlist_.fontIterator(from); + if (cit == d->fontlist_.end()) + return; + Language const * lang = cit->font().language(); + docstring const word = asString(from, pos, AS_STR_NONE); + d->words_[lang->lang()].insert(word); } }