]> git.lyx.org Git - lyx.git/commitdiff
#9514 contents inside of LyX insets with spell check disabled should be ignored by...
authorStephan Witt <switt@lyx.org>
Wed, 6 May 2015 16:39:24 +0000 (18:39 +0200)
committerStephan Witt <switt@lyx.org>
Wed, 6 May 2015 16:39:24 +0000 (18:39 +0200)
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.

src/Buffer.cpp
src/MetricsInfo.cpp
src/MetricsInfo.h
src/RowPainter.cpp
src/TextMetrics.cpp

index 194cd9bef07d4c48a73093f9a052e27951f9edc4..fb3602691d1d477c2d06ed28b6902d8a11afd5a9 100644 (file)
@@ -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) {
index b75ec811086a70ebdaa777191ed27cdf2dc66033..2b954d3ed96d12926f78963c9f84cfb74587c6aa 100644 (file)
@@ -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;
 }
index 88dd39fd7d7e5958b5eba94972d9aa3adf7c7c53..7ad62426e7c9a887f231a635dfa28afe6a3136eb 100644 (file)
@@ -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
index 4c9118d916fe37698c75778f92bca8efd68fe457..fbe35792a201b0462095de6cbbbfaa9f5dc94b3e 100644 (file)
@@ -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;
index 59eb2abd719269237c8314f32ccef4dc690b566e..a347b993ec618ce7244668b7548999ff1a4e9f62 100644 (file)
@@ -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();
                }