]> git.lyx.org Git - lyx.git/commitdiff
Fixup 65cb9fa4: avoid extra spacing when selecting math
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 18 Oct 2023 10:28:47 +0000 (12:28 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 18 Oct 2023 10:30:55 +0000 (12:30 +0200)
This was happening whenever a selection started/ended after a fraction
inset.

src/mathed/MathRow.cpp

index 15e430fc3a87a51a5973d7745672533aa877bff6..7b5ff9e1d0075f21dae0d0705bdb8d8cad023d5d 100644 (file)
@@ -186,8 +186,8 @@ MathRow::MathRow(MetricsInfo & mi, MathData const * ar)
        // We go to the end to handle spacing at the end of equation
        for (int i = 1 ; i != static_cast<int>(elements_.size()) ; ++i) {
                Element & e = elements_[i];
-
                Element & bef = elements_[before(i)];
+
                if (dospacing && e.mclass != MC_UNKNOWN) {
                        int spc = class_spacing(bef.mclass, e.mclass, mi.base);
                        bef.after += spc / 2;
@@ -196,7 +196,15 @@ MathRow::MathRow(MetricsInfo & mi, MathData const * ar)
                }
 
                // finally reserve space for markers
-               bef.after = max(bef.after, markerMargin(bef));
+               /* FIXME : the test below avoids that the spacing grows grows
+                * when a BEGIN/END_SEL element is added (typically start or
+                * end a selection after a fraction). I would think that the
+                * code should just go under the e.mclass != MC_UNKNOWN branch
+                * below, but I am not sure why it has not been done before.
+                * Therefore, until we double check this, be very conservative
+                */
+               if (e.type != BEGIN_SEL && e.type != END_SEL)
+                       bef.after = max(bef.after, markerMargin(bef));
                if (e.mclass != MC_UNKNOWN)
                        e.before = max(e.before, markerMargin(e));
                // for linearized insets (macros...) too