From 8c8675e2ca675978634385dadb7cb08b2ea7da64 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Sat, 12 Dec 2009 02:56:06 +0000 Subject: [PATCH] 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 --- src/Buffer.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index e827bc9780..1a37dcc210 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -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; } -- 2.39.2