From ff7696f184e1065048d81954ef2c9a9d27b4f026 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 12 Oct 2023 11:28:44 +0200 Subject: [PATCH] Do not use Color_selectionmath when selection is gone 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mathed/MathRow.cpp b/src/mathed/MathRow.cpp index 8e46b59047..15e430fc3a 100644 --- a/src/mathed/MathRow.cpp +++ b/src/mathed/MathRow.cpp @@ -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(); -- 2.39.5