Fix a crash when spellchecking when a Math inset is the last inset in the document. Make sure that the words between a math inset and the next inset are spellchecked. Also fix the count of the number of words when there are math insets.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32489 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-12-12 02:56:06 +00:00
parent 8515bea89a
commit 8c8675e2ca

View File

@ -3735,15 +3735,26 @@ int Buffer::spellCheck(DocIterator & from, DocIterator & to,
DocIterator const end = doc_iterator_end(this);
for (; from != end; from.forwardPos()) {
// We are only interested in text so remove the math CursorSlice.
while (from.inMathed())
from.forwardInset();
while (from.inMathed()) {
from.pop_back();
from.pos()++;
}
// If from is at the end of the document (which is possible
// when leaving the mathed) LyX will crash later.
if (from == end)
break;
to = from;
if (from.paragraph().spellCheck(from.pos(), to.pos(), wl, suggestions)) {
word_lang = wl;
break;
}
from = to;
++progress;
// Do not increase progress when from == to, otherwise the word
// count will be wrong.
if (from != to) {
from = to;
++progress;
}
}
return progress;
}