]> git.lyx.org Git - lyx.git/commitdiff
Do not use Color_selectionmath when selection is gone
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 12 Oct 2023 09:28:44 +0000 (11:28 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 12 Oct 2023 09:30:47 +0000 (11:30 +0200)
It might happen that the selection goes away without recomputing
metrics (for example with char-forward). The added test is a bit of a
band-aid for this situation. A better solution would be to understand
better when metrics computation is triggered in mathed.

src/mathed/MathRow.cpp

index 8e46b59047f63e4e8fbce4befa5ee38bcb086826..15e430fc3a87a51a5973d7745672533aa877bff6 100644 (file)
@@ -18,6 +18,7 @@
 #include "BufferView.h"
 #include "ColorSet.h"
 #include "CoordCache.h"
+#include "Cursor.h"
 #include "LyXRC.h"
 #include "MetricsInfo.h"
 
@@ -356,7 +357,11 @@ void MathRow::draw(PainterInfo & pi, int x, int const y) const
                        x += e.before + e.after;
                        break;
                case BEGIN_SEL:
-                       change_color = pi.base.font.changeColor(Color_selectionmath);
+                       // Change the color if the selection is indeed active
+                       // FIXME: it would be better to make sure that metrics are
+                       //   computed again when selection status changes.
+                       if (pi.base.bv->cursor().selection())
+                               change_color = pi.base.font.changeColor(Color_selectionmath);
                        break;
                case END_SEL:
                        change_color = noChange();