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.
This commit is contained in:
Jean-Marc Lasgouttes 2023-10-12 11:28:44 +02:00
parent 174dc2c8be
commit ff7696f184

View 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();