commit 1bdba953a54769d449624bc5c53bfaa9c59ac461
Author: Enrico Forestieri <for...@lyx.org>
Date:   Mon Nov 12 19:05:09 2018 +0100

    Fix cursor left/right navigation in overset, underset, and stackrel
    
    Before this commit, navigating with the cursor was visiting either
    the nucleus or the script depending on the direction (left or right)
    of the cursor movement. Now the 2.3.x behavior of always going through
    the nucleus is restored (at least for overset and underset, as stackrel
    seems to behave oddly also in 2.3.x).
---
 src/mathed/InsetMathOverset.cpp  |   18 ++++++++++++++++++
 src/mathed/InsetMathOverset.h    |    4 ++++
 src/mathed/InsetMathStackrel.cpp |   20 ++++++++++++++++++++
 src/mathed/InsetMathStackrel.h   |    4 ++++
 src/mathed/InsetMathUnderset.cpp |   19 +++++++++++++++++++
 src/mathed/InsetMathUnderset.h   |    4 ++++
 6 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/src/mathed/InsetMathOverset.cpp b/src/mathed/InsetMathOverset.cpp
index 9d835f0..3d36218 100644
--- a/src/mathed/InsetMathOverset.cpp
+++ b/src/mathed/InsetMathOverset.cpp
@@ -70,6 +70,24 @@ bool InsetMathOverset::idxUpDown(Cursor & cur, bool up) const
 }
 
 
+bool InsetMathOverset::idxFirst(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 0;
+       cur.pos() = 0;
+       return true;
+}
+
+
+bool InsetMathOverset::idxLast(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 0;
+       cur.pos() = cur.lastpos();
+       return true;
+}
+
+
 void InsetMathOverset::write(WriteStream & os) const
 {
        MathEnsurer ensurer(os);
diff --git a/src/mathed/InsetMathOverset.h b/src/mathed/InsetMathOverset.h
index eb6b86b..213c96f 100644
--- a/src/mathed/InsetMathOverset.h
+++ b/src/mathed/InsetMathOverset.h
@@ -30,6 +30,10 @@ public:
        ///
        bool idxUpDown(Cursor & cur, bool up) const;
        ///
+       bool idxFirst(Cursor &) const;
+       ///
+       bool idxLast(Cursor &) const;
+       ///
        void write(WriteStream & os) const;
        ///
        void normalize(NormalStream &) const;
diff --git a/src/mathed/InsetMathStackrel.cpp b/src/mathed/InsetMathStackrel.cpp
index 9a9c66f..430d8f1 100644
--- a/src/mathed/InsetMathStackrel.cpp
+++ b/src/mathed/InsetMathStackrel.cpp
@@ -19,6 +19,8 @@
 #include "LaTeXFeatures.h"
 #include "MetricsInfo.h"
 
+#include "support/lassert.h"
+
 using namespace std;
 
 namespace lyx {
@@ -54,6 +56,24 @@ bool InsetMathStackrel::idxUpDown(Cursor & cur, bool up) 
const
 }
 
 
+bool InsetMathStackrel::idxFirst(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 0;
+       cur.pos() = 0;
+       return true;
+}
+
+
+bool InsetMathStackrel::idxLast(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 0;
+       cur.pos() = cur.lastpos();
+       return true;
+}
+
+
 MathClass InsetMathStackrel::mathClass() const
 {
        // FIXME: update this when/if \stackbin is supported
diff --git a/src/mathed/InsetMathStackrel.h b/src/mathed/InsetMathStackrel.h
index d6ac815..5740fb9 100644
--- a/src/mathed/InsetMathStackrel.h
+++ b/src/mathed/InsetMathStackrel.h
@@ -24,6 +24,10 @@ public:
        ///
        bool idxUpDown(Cursor &, bool up) const;
        ///
+       bool idxFirst(Cursor &) const;
+       ///
+       bool idxLast(Cursor &) const;
+       ///
        MathClass mathClass() const;
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
diff --git a/src/mathed/InsetMathUnderset.cpp b/src/mathed/InsetMathUnderset.cpp
index 794427e..832631d 100644
--- a/src/mathed/InsetMathUnderset.cpp
+++ b/src/mathed/InsetMathUnderset.cpp
@@ -19,6 +19,7 @@
 #include "LaTeXFeatures.h"
 #include "MetricsInfo.h"
 
+#include "support/lassert.h"
 
 using namespace std;
 
@@ -58,6 +59,24 @@ void InsetMathUnderset::draw(PainterInfo & pi, int x, int y) 
const
 }
 
 
+bool InsetMathUnderset::idxFirst(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 0;
+       cur.pos() = 0;
+       return true;
+}
+
+
+bool InsetMathUnderset::idxLast(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 0;
+       cur.pos() = cur.lastpos();
+       return true;
+}
+
+
 void InsetMathUnderset::write(WriteStream & os) const
 {
        MathEnsurer ensurer(os);
diff --git a/src/mathed/InsetMathUnderset.h b/src/mathed/InsetMathUnderset.h
index fbc3e77..50143ae 100644
--- a/src/mathed/InsetMathUnderset.h
+++ b/src/mathed/InsetMathUnderset.h
@@ -28,6 +28,10 @@ public:
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
+       bool idxFirst(Cursor &) const;
+       ///
+       bool idxLast(Cursor &) const;
+       ///
        void write(WriteStream & ws) const;
        ///
        void normalize(NormalStream & ns) const;

Reply via email to