Am 28.01.2011 um 08:05 schrieb Stephan Witt:

> Am 28.01.2011 um 00:06 schrieb Jean-Marc Lasgouttes:
> 
>> Le 27 janv. 2011 à 21:49, Stephan Witt a écrit :
>>> Yes, it is.
>>> The innermost loop in method RowPainter::paintChars() stops at printable 
>>> spaces.
>>> After returning and drawing the misspelled marker the space is not painted 
>>> but skipped.
>>> 
>>> The normal spell checker stops at word boundaries anyway.
>>> 
>>> So I want to apply the patch.
>> 
>> Please do.
> 
> I did it. I have to check the "do not mark the word at cursor position" 
> feature again.

It has shown the following patch is needed. Ok?

Stephan


Index: src/Paragraph.h
===================================================================
--- src/Paragraph.h     (Revision 37347)
+++ src/Paragraph.h     (Arbeitskopie)
@@ -456,7 +456,7 @@
 
        /// Spell checker status at position \p pos.
        /// \return true if pointed position is misspelled.
-       bool isMisspelled(pos_type pos) const;
+       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: src/Paragraph.cpp
===================================================================
--- src/Paragraph.cpp   (Revision 37347)
+++ src/Paragraph.cpp   (Arbeitskopie)
@@ -3762,9 +3762,12 @@
 }
 
 
-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: src/Text3.cpp
===================================================================
--- src/Text3.cpp       (Revision 37347)
+++ src/Text3.cpp       (Arbeitskopie)
@@ -71,6 +71,7 @@
 #include "support/lstrings.h"
 #include "support/lyxtime.h"
 #include "support/os.h"
+#include "support/textutils.h"
 
 #include "mathed/InsetMathHull.h"
 #include "mathed/MathMacroTemplate.h"
@@ -467,9 +468,9 @@
        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 +478,8 @@
        // 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 +2184,10 @@
                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 +2213,7 @@
        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
                //

Reply via email to