commit 93b0f9c080cbb3dd807850ad60dbe211fc5bc703
Author: Stephan Witt <[email protected]>
Date:   Wed May 6 18:39:24 2015 +0200

    #9514 contents inside of LyX insets with spell check disabled should be 
ignored by spell checker.
    The document iterator now skips math insets and insets like notes where 
spell check is disabled.
    The continuous spell checking is part of the row painter drawing and the 
spell check disabled state
    has to be passed down recursively while doing the inset painting.

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 194cd9b..fb36026 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -4809,12 +4809,13 @@ int Buffer::spellCheck(DocIterator & from, DocIterator 
& to,
        // OK, we start from here.
        for (; from != end; from.forwardPos()) {
                // We are only interested in text so remove the math 
CursorSlice.
-               while (from.inMathed()) {
+               // The same is done for insets with disabled spell check.
+               while (from.inMathed() || !from.inset().allowSpellCheck()) {
                        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 otherwise.
+               // when "from" was manipulated) LyX will crash later otherwise.
                if (from.atEnd() || (!to_end && from >= end))
                        break;
                to = from;
@@ -4824,7 +4825,6 @@ int Buffer::spellCheck(DocIterator & from, DocIterator & 
to,
                        word_lang = wl;
                        break;
                }
-
                // Do not increase progress when from == to, otherwise the word
                // count will be wrong.
                if (from != to) {
diff --git a/src/MetricsInfo.cpp b/src/MetricsInfo.cpp
index b75ec81..2b954d3 100644
--- a/src/MetricsInfo.cpp
+++ b/src/MetricsInfo.cpp
@@ -66,7 +66,7 @@ MetricsInfo::MetricsInfo(BufferView * bv, FontInfo const & 
font, int textwidth,
 
 PainterInfo::PainterInfo(BufferView * bv, lyx::frontend::Painter & painter)
        : pain(painter), ltr_pos(false), change_(), selected(false),
-       full_repaint(true), background_color(Color_background)
+       do_spellcheck(true), full_repaint(true), 
background_color(Color_background)
 {
        base.bv = bv;
 }
diff --git a/src/MetricsInfo.h b/src/MetricsInfo.h
index 88dd39f..7ad6242 100644
--- a/src/MetricsInfo.h
+++ b/src/MetricsInfo.h
@@ -117,6 +117,8 @@ public:
        Change change_;
        /// Whether the parent is selected as a whole
        bool selected;
+       /// Whether the spell checker is enabled for the parent
+       bool do_spellcheck;
        ///
        bool full_repaint;
        /// Current background color
diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index 4c9118d..fbe3579 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -121,13 +121,15 @@ void RowPainter::paintInset(Inset const * inset, pos_type 
const pos)
        LASSERT(inset, return);
        // Backup full_repaint status because some insets (InsetTabular)
        // requires a full repaint
-       bool pi_full_repaint = pi_.full_repaint;
+       bool const pi_full_repaint = pi_.full_repaint;
+       bool const pi_do_spellcheck = pi_.do_spellcheck;
 
        pi_.base.font = inset->inheritFont() ? font.fontInfo() :
                pi_.base.bv->buffer().params().getFont().fontInfo();
        pi_.ltr_pos = (bidi_.level(pos) % 2 == 0);
        Change prev_change = change_;
        pi_.change_ = change_.changed() ? change_ : par_.lookupChange(pos);
+       pi_.do_spellcheck &= inset->allowSpellCheck();
 
        int const x1 = int(x_);
        pi_.base.bv->coordCache().insets().add(inset, x1, yo_);
@@ -147,6 +149,7 @@ void RowPainter::paintInset(Inset const * inset, pos_type 
const pos)
        // Restore full_repaint status.
        pi_.full_repaint = pi_full_repaint;
        pi_.change_ = prev_change;
+       pi_.do_spellcheck = pi_do_spellcheck;
 
 #ifdef DEBUG_METRICS
        int const x2 = x1 + dim.wid;
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 59eb2ab..a347b99 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -1878,7 +1878,7 @@ void TextMetrics::drawParagraph(PainterInfo & pi, 
pit_type const pit, int const
                        || rowSlice == bv_->lastRowSlice();
 
                // Take this opportunity to spellcheck the row contents.
-               if (row_has_changed && lyxrc.spellcheck_continuously) {
+               if (row_has_changed && pi.do_spellcheck && 
lyxrc.spellcheck_continuously) {
                        text_->getPar(pit).spellCheck();
                }
 

Reply via email to