Jean-Marc Lasgouttes wrote:
> -void MathNestInset::notifyCursorLeaves(LCursor & cur)
> +bool MathNestInset::notifyCursorLeaves(LCursor & cur)
>  {
>  #ifdef WITH_WARNINGS
>  #warning look here
> @@ -373,6 +373,7 @@ void MathNestInset::notifyCursorLeaves(L
>                 }
>         }
>  #endif
> +       return false;
>  }


FWIW, I have reimplemented MathNestInset::notifyCursorLeaves some time ago 
(just getting it into its previous state again). Maybe this is of interest?

Jürgen
Index: src/mathed/math_nestinset.C
===================================================================
--- src/mathed/math_nestinset.C	(Revision 14784)
+++ src/mathed/math_nestinset.C	(Arbeitskopie)
@@ -21,6 +21,7 @@
 #include "math_data.h"
 #include "math_deliminset.h"
 #include "math_factory.h"
+#include "math_fontinset.h"
 #include "math_hullinset.h"
 #include "math_mathmlstream.h"
 #include "math_macroarg.h"
@@ -350,35 +351,44 @@ int MathNestInset::latex(Buffer const &,
 }
 
 
-void MathNestInset::notifyCursorLeaves(LCursor & /*cur*/)
+void MathNestInset::notifyCursorLeaves(LCursor & cur)
 {
-#ifdef WITH_WARNINGS
-#warning look here
-#endif
-#if 0
 	MathArray & ar = cur.cell();
 	// remove base-only "scripts"
 	for (pos_type i = 0; i + 1 < ar.size(); ++i) {
-		MathScriptInset * p = operator[](i).nucleus()->asScriptInset();
+		MathScriptInset * p = ar[i].nucleus()->asScriptInset();
 		if (p && p->nargs() == 1) {
 			MathArray ar = p->nuc();
-			erase(i);
-			insert(i, ar);
-			cur.adjust(i, ar.size() - 1);
+			ar.erase(i);
+			ar.insert(i, ar);
+			// (reimplementation of old math_cursor::adjust):
+			if (cur.pos() > i) {
+				cur.pos() += (ar.size() - 1);
+				cur.resetAnchor();
+			}
+			// just to be on the safe side
+			// theoretically not necessary
+			cur.normalize();
 		}
 	}
 
 	// glue adjacent font insets of the same kind
-	for (pos_type i = 0; i + 1 < size(); ++i) {
-		MathFontInset * p = operator[](i).nucleus()->asFontInset();
-		MathFontInset const * q = operator[](i + 1)->asFontInset();
+	for (pos_type i = 0; i + 1 < ar.size(); ++i) {
+		MathFontInset * p = ar[i].nucleus()->asFontInset();
+		MathFontInset const * q = ar[i + 1]->asFontInset();
 		if (p && q && p->name() == q->name()) {
 			p->cell(0).append(q->cell(0));
-			erase(i + 1);
-			cur.adjust(i, -1);
+			ar.erase(i + 1);
+			// (reimplementation of old math_cursor::adjust):
+			if (cur.pos() > i) {
+				cur.pos() += (ar.size() - 1);
+				cur.resetAnchor();
+			}
+			// just to be on the safe side
+			// theoretically not necessary
+			cur.normalize();
 		}
 	}
-#endif
 }
 
 

Reply via email to