From 99ecdd6cebaaaf6bf8e8123411475d26df9c358c Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 18 Oct 2023 12:28:47 +0200 Subject: [PATCH] Fixup 65cb9fa4: avoid extra spacing when selecting math This was happening whenever a selection started/ended after a fraction inset. --- src/mathed/MathRow.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mathed/MathRow.cpp b/src/mathed/MathRow.cpp index 15e430fc3a..7b5ff9e1d0 100644 --- a/src/mathed/MathRow.cpp +++ b/src/mathed/MathRow.cpp @@ -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(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