commit e93444e7e9d6f1aeabd356d414d4e5af3cea8569
Author: Stephan Witt <[email protected]>
Date:   Fri May 8 11:13:32 2015 +0200

    #9514 improved document iterator for correct check of speller disabled state

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index fb36026..e12d830 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -4808,14 +4808,13 @@ int Buffer::spellCheck(DocIterator & from, DocIterator 
& to,
        DocIterator const end = to_end ? doc_iterator_end(this) : to;
        // OK, we start from here.
        for (; from != end; from.forwardPos()) {
-               // We are only interested in text so remove the math 
CursorSlice.
-               // The same is done for insets with disabled spell check.
-               while (from.inMathed() || !from.inset().allowSpellCheck()) {
+               // This skips all insets with spell check disabled.
+               while (!from.allowSpellCheck()) {
                        from.pop_back();
                        from.pos()++;
                }
                // If from is at the end of the document (which is possible
-               // when "from" was manipulated) LyX will crash later otherwise.
+               // when "from" was changed above) LyX will crash later 
otherwise.
                if (from.atEnd() || (!to_end && from >= end))
                        break;
                to = from;
diff --git a/src/DocIterator.cpp b/src/DocIterator.cpp
index 4dbd261..9783db1 100644
--- a/src/DocIterator.cpp
+++ b/src/DocIterator.cpp
@@ -482,6 +482,19 @@ bool DocIterator::hasPart(DocIterator const & it) const
 }
 
 
+bool DocIterator::allowSpellCheck() const
+{
+       /// spell check is disabled if the iterator position
+       /// is inside of an inset which disables the spell checker
+       size_t const n = depth();
+       for (size_t i = 0; i < n; ++i) {
+               if (!slices_[i].inset_->allowSpellCheck())
+                       return false;
+       }
+       return true;
+}
+
+
 void DocIterator::updateInsets(Inset * inset)
 {
        // this function re-creates the cache of inset pointers.
diff --git a/src/DocIterator.h b/src/DocIterator.h
index 6a86e41..74dd474 100644
--- a/src/DocIterator.h
+++ b/src/DocIterator.h
@@ -75,6 +75,9 @@ public:
        /// is this the last possible position?
        bool atLastPos() const { return pit() == lastpit() && pos() == 
lastpos(); }
 
+       /// checks the cursor slices for disabled spell checker insets
+       bool allowSpellCheck() const;
+
        //
        // access to slice at tip
        //
diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index fbe3579..d556cfa 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -330,8 +330,8 @@ void RowPainter::paintFromPos(pos_type & vpos, bool changed)
                                --cpos;
                        new_word = par_.isSameSpellRange(pos, cpos) ;
                }
-               if (!new_word)
-                       paintMisspelledMark(orig_x, changed);
+               if (!new_word && pi_.do_spellcheck)
+                       paintMisspelledMark(orig_x, changed, font);
        }
 }
 

Reply via email to