Attached is a fix for (1) and (2) (but not (3)) of bug 3551 (http://bugzilla.lyx.org/show_bug.cgi?id=3551). I'd be happy to hear any comments, I'm not sure that I understand everything that I did, but it does work.

Dov

Index: src/Text3.cpp
===================================================================
--- src/Text3.cpp       (revision 18205)
+++ src/Text3.cpp       (working copy)
@@ -433,7 +433,7 @@
                //lyxerr << BOOST_CURRENT_FUNCTION
                //       << " LFUN_CHAR_FORWARD[SEL]:\n" << cur << endl;
                needsUpdate |= cur.selHandle(cmd.action == 
LFUN_CHAR_FORWARD_SELECT);
-               if (isRTL(*cur.bv().buffer(), cur.paragraph()))
+               if (isRTL(*cur.bv().buffer(), cur.outerParagraph()))
                        needsUpdate |= cursorLeft(cur);
                else
                        needsUpdate |= cursorRight(cur);
@@ -451,7 +451,7 @@
        case LFUN_CHAR_BACKWARD_SELECT:
                //lyxerr << "handle LFUN_CHAR_BACKWARD[_SELECT]:\n" << cur << 
endl;
                needsUpdate |= cur.selHandle(cmd.action == 
LFUN_CHAR_BACKWARD_SELECT);
-               if (isRTL(*cur.bv().buffer(), cur.paragraph()))
+               if (isRTL(*cur.bv().buffer(), cur.outerParagraph()))
                        needsUpdate |= cursorRight(cur);
                else
                        needsUpdate |= cursorLeft(cur);
@@ -557,7 +557,7 @@
        case LFUN_WORD_FORWARD:
        case LFUN_WORD_FORWARD_SELECT:
                needsUpdate |= cur.selHandle(cmd.action == 
LFUN_WORD_FORWARD_SELECT);
-               if (isRTL(*cur.bv().buffer(), cur.paragraph()))
+               if (isRTL(*cur.bv().buffer(), cur.outerParagraph()))
                        needsUpdate |= cursorLeftOneWord(cur);
                else
                        needsUpdate |= cursorRightOneWord(cur);
@@ -568,7 +568,7 @@
        case LFUN_WORD_BACKWARD:
        case LFUN_WORD_BACKWARD_SELECT:
                needsUpdate |= cur.selHandle(cmd.action == 
LFUN_WORD_BACKWARD_SELECT);
-               if (isRTL(*cur.bv().buffer(), cur.paragraph()))
+               if (isRTL(*cur.bv().buffer(), cur.outerParagraph()))
                        needsUpdate |= cursorRightOneWord(cur);
                else
                        needsUpdate |= cursorLeftOneWord(cur);
@@ -1433,11 +1433,16 @@
 
        case LFUN_FINISHED_LEFT:
                LYXERR(Debug::DEBUG) << "handle LFUN_FINISHED_LEFT:\n" << cur 
<< endl;
+               if (isRTL(*cur.bv().buffer(), cur.outerParagraph())) {
+                       ++cur.pos();
+               }
                break;
 
        case LFUN_FINISHED_RIGHT:
                LYXERR(Debug::DEBUG) << "handle LFUN_FINISHED_RIGHT:\n" << cur 
<< endl;
-               ++cur.pos();
+               if (!isRTL(*cur.bv().buffer(), cur.outerParagraph())) {
+                       ++cur.pos();
+               }
                break;
 
        case LFUN_FINISHED_UP:
Index: src/DocIterator.h
===================================================================
--- src/DocIterator.h   (revision 18205)
+++ src/DocIterator.h   (working copy)
@@ -162,6 +162,8 @@
        /// This method will give the containing paragraph if
        /// in not in text mode (ex: in mathed).
        Paragraph const & innerParagraph() const;
+       /// the outermost paragraph within which we're currently nested.
+       Paragraph const & outerParagraph() const;
        ///
        Text * text();
        ///
Index: src/DocIterator.cpp
===================================================================
--- src/DocIterator.cpp (revision 18205)
+++ src/DocIterator.cpp (working copy)
@@ -196,6 +196,11 @@
        return paragraph();
 }
 
+Paragraph const & DocIterator::outerParagraph() const
+{
+       BOOST_ASSERT(!empty());
+       return bottom().paragraph();
+}
 
 pit_type DocIterator::lastpit() const
 {

Reply via email to