commit 7eecab590280892d1dab85298366d0033bbf0e39
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Sat Sep 2 17:15:20 2023 +0200

    Check whether MathRow exists when computing caret metrics
    
    Fixes bug #12888.
---
 src/BufferView.cpp |    8 +++++++-
 src/BufferView.h   |    2 ++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 9ec5df3..4531bda 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -435,6 +435,12 @@ CoordCache const & BufferView::coordCache() const
 }
 
 
+bool BufferView::hasMathRow(MathData const * cell) const
+{
+       return d->math_rows_.find(cell) != d->math_rows_.end();
+}
+
+
 MathRow const & BufferView::mathRow(MathData const * cell) const
 {
        auto it = d->math_rows_.find(cell);
@@ -3323,7 +3329,7 @@ bool BufferView::paragraphVisible(DocIterator const & 
dit) const
 void BufferView::caretPosAndDim(Point & p, Dimension & dim) const
 {
        Cursor const & cur = cursor();
-       if (cur.inMathed()) {
+       if (cur.inMathed() && hasMathRow(&cur.cell())) {
                MathRow const & mrow = mathRow(&cur.cell());
                dim = mrow.caret_dim;
        } else {
diff --git a/src/BufferView.h b/src/BufferView.h
index b64b431..f816eda 100644
--- a/src/BufferView.h
+++ b/src/BufferView.h
@@ -322,6 +322,8 @@ public:
        CoordCache const & coordCache() const;
 
        ///
+       bool hasMathRow(MathData const * cell) const;
+       ///
        MathRow const & mathRow(MathData const * cell) const;
        ///
        void setMathRow(MathData const * cell, MathRow const & mrow);
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to