Check whether MathRow exists when computing caret metrics

Fixes bug #12888.
This commit is contained in:
Jean-Marc Lasgouttes 2023-09-02 17:15:20 +02:00
parent e651e15a99
commit 7eecab5902
2 changed files with 9 additions and 1 deletions

View File

@ -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 {

View File

@ -321,6 +321,8 @@ public:
///
CoordCache const & coordCache() const;
///
bool hasMathRow(MathData const * cell) const;
///
MathRow const & mathRow(MathData const * cell) const;
///