]> git.lyx.org Git - features.git/commitdiff
restore the correct behavior of suppression of misspelled marker for word at cursor...
authorStephan Witt <switt@lyx.org>
Sat, 29 Jan 2011 12:28:02 +0000 (12:28 +0000)
committerStephan Witt <switt@lyx.org>
Sat, 29 Jan 2011 12:28:02 +0000 (12:28 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37363 a592a061-630c-0410-9148-cb99ea01b6c8

src/Paragraph.cpp
src/Paragraph.h
src/Text3.cpp
src/rowpainter.cpp

index b8db16590caaf2eae6882172eeb823ae02168844..08b143b3646fe78e8c62f49726b6b6c87c7c1d20 100644 (file)
@@ -3763,9 +3763,12 @@ void Paragraph::spellCheck() const
 }
 
 
-bool Paragraph::isMisspelled(pos_type pos) const
+bool Paragraph::isMisspelled(pos_type pos, bool check_boundary) const
 {
-       return SpellChecker::misspelled(d->speller_state_.getState(pos));
+       bool result = SpellChecker::misspelled(d->speller_state_.getState(pos));
+       if (!result && check_boundary && pos > 0 && isWordSeparator(pos))
+               result = SpellChecker::misspelled(d->speller_state_.getState(pos - 1));
+       return result;
 }
 
 
index ed8d7f4027e3edc641b1aaea0c6263b38db54391..9ab52ed01b0f0f8b8b77fd47483224c69d8b31ed 100644 (file)
@@ -456,8 +456,10 @@ public:
                bool check_learned = false) const;
 
        /// Spell checker status at position \p pos.
-       /// \return true if pointed position is misspelled.
-       bool isMisspelled(pos_type pos) const;
+       /// If \p check_boundary is true the status of position immediately
+       /// before \p pos is tested too if it is at word boundary.
+       /// \return true if one of the tested positions is misspelled.
+       bool isMisspelled(pos_type pos, bool check_boundary = false) const;
 
        /// \return true if both positions are inside the same
        /// spell range - i.e. the same word.
index 5079522bb47e3ab1f8aa425eeb74c68b8495ad57..dad691b6d103ca00bdb2a92752146d86ae8c4554 100644 (file)
@@ -467,9 +467,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        cur.noScreenUpdate();
 
        LASSERT(cur.text() == this, /**/);
-       CursorSlice oldTopSlice = cur.top();
-       bool oldBoundary = cur.boundary();
-       bool sel = cur.selection();
+       CursorSlice const oldTopSlice = cur.top();
+       bool const oldBoundary = cur.boundary();
+       bool const oldSelection = cur.selection();
        // Signals that, even if needsUpdate == false, an update of the
        // cursor paragraph is required
        bool singleParUpdate = lyxaction.funcHasFlag(cmd.action(),
@@ -477,9 +477,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        // Signals that a full-screen update is required
        bool needsUpdate = !(lyxaction.funcHasFlag(cmd.action(),
                LyXAction::NoUpdate) || singleParUpdate);
-       int const last_pid = cur.paragraph().id();
-       pos_type const last_pos = cur.pos();
-       bool const last_misspelled = lyxrc.spellcheck_continuously && cur.paragraph().isMisspelled(cur.pos());
+       bool const last_misspelled = lyxrc.spellcheck_continuously
+               && cur.paragraph().isMisspelled(cur.pos(), true);
        
        FuncCode const act = cmd.action();
        switch (act) {
@@ -2184,9 +2183,10 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                if (!cur.inTexted()) {
                        // move from regular text to math
                        needsUpdate = last_misspelled;
-               } else if (cur.paragraph().id() != last_pid || cur.pos() != last_pos) {
+               } else if (oldTopSlice != cur.top() || oldBoundary != cur.boundary()) {
                        // move inside regular text
-                       needsUpdate = last_misspelled || cur.paragraph().isMisspelled(cur.pos());
+                       needsUpdate = last_misspelled
+                               || cur.paragraph().isMisspelled(cur.pos(), true);
                }
        }
 
@@ -2212,7 +2212,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        if (!needsUpdate
            && &oldTopSlice.inset() == &cur.inset()
            && oldTopSlice.idx() == cur.idx()
-           && !sel // sel is a backup of cur.selection() at the beginning of the function.
+           && !oldSelection // oldSelection is a backup of cur.selection() at the beginning of the function.
            && !cur.selection())
                // FIXME: it would be better if we could just do this
                //
index 5ea2ffc8753df92b0cf9c03472f8df1c0879a938..5d0bcb6b2850e11ac51c091ad3b53d2ede810071 100644 (file)
@@ -421,6 +421,8 @@ void RowPainter::paintFromPos(pos_type & vpos, bool changed)
                        pos_type cpos = cur.pos();
                        if (cpos > 0 && cpos == par_.size() && !par_.isWordSeparator(cpos-1))
                                --cpos;
+                       else if (cpos > 0 && par_.isWordSeparator(cpos))
+                               --cpos;
                        current_word = par_.isSameSpellRange(pos, cpos) ;
                }
                if (!current_word)