[LyX/2.1.x] Do not forget last word of paragraph in completion

2014-07-19 Thread Jean-Marc Lasgouttes
commit 3e60f58a92e6860d904b8c1373b9968603a1d180
Author: Jean-Marc Lasgouttes lasgout...@lyx.org
Date:   Fri May 16 15:17:10 2014 +0200

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 fccc28f..81ca225 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -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);
}
 }
 
diff --git a/status.21x b/status.21x
index 3db8551..46333c2 100644
--- a/status.21x
+++ b/status.21x
@@ -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


[LyX/2.1.x] Do not forget last word of paragraph in completion

2014-07-19 Thread Jean-Marc Lasgouttes
commit 3e60f58a92e6860d904b8c1373b9968603a1d180
Author: Jean-Marc Lasgouttes 
Date:   Fri May 16 15:17:10 2014 +0200

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 fccc28f..81ca225 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -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);
}
 }
 
diff --git a/status.21x b/status.21x
index 3db8551..46333c2 100644
--- a/status.21x
+++ b/status.21x
@@ -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