]> git.lyx.org Git - features.git/commitdiff
Do not forget last word of paragraph in completion
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 16 May 2014 13:17:10 +0000 (15:17 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 19 Jul 2014 22:07:23 +0000 (00:07 +0200)
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.

src/Paragraph.cpp
status.21x

index fccc28f95164666a004d23ec8ad5b64e11d3d9ed..81ca22574bd0d131ec6556eb0c1bfe041280d0d1 100644 (file)
@@ -3861,20 +3861,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);
        }
 }
 
index 3db8551e175a5c6d197ceda8329c225643da5b4f..46333c2f2bc9a367784bfe46fd66a202977c9c6b 100644 (file)
@@ -55,12 +55,14 @@ What's new
 
 * LYX2LYX
 
-- Fix warning "Missing \use_indices" when converting from 1.6.x format or older
+- Fix warning "Missing \use_indices" when converting from 1.6.x format
+  or older.
 
 
 
 * USER INTERFACE
 
+- Do not forget last words of paragraphs in completion possibilities.
 
 
 * INTERNALS