X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FTextMetrics.cpp;h=3dd052059b44e39d86c07b5eaba743f2631ed59e;hb=2a0e4c199c4f18d80ec5a2ab452f3cf18eafc56c;hp=87a381eed0d09a66e436728cf0cba2c75d8464c1;hpb=eb4a2a190f2640d2a6ab7146cfcc347e70b57044;p=lyx.git diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 87a381eed0..3dd052059b 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -482,11 +482,11 @@ bool TextMetrics::redoParagraph(pit_type const pit) if (text_->isMainText()) { if (pit == 0) { pm.rows().front().dimension().asc += 20; - /* coverity[copy_paste_error]: coverity thinks that we - * should update pm.dim().asc below, but all the rows - * heights are actually counted as part of the paragraph metric - * descent see loop above). + /* coverity thinks that we should update pm.dim().asc + * below, but all the rows heights are actually counted as + * part of the paragraph metric descent see loop above). */ + // coverity[copy_paste_error] pm.dim().des += 20; } ParagraphList const & pars = text_->paragraphs(); @@ -1361,18 +1361,23 @@ Inset * TextMetrics::editXY(Cursor & cur, int x, int y, if (edited == inset && cur.pos() == it->pos) { // non-editable inset, set cursor after the inset if x is // nearer to that position (bug 9628) + // TODO: This should be replaced with an improvement of + // Cursor::moveToClosestEdge that handles rtl text. (Which could not + // be tested because of #10569.) CoordCache::Insets const & insetCache = bv_->coordCache().getInsets(); - Dimension const & dim = insetCache.dim(inset); - Point p = insetCache.xy(inset); - bool const is_rtl = text_->isRTL(text_->getPar(pit)); - if (is_rtl) { - // "in front of" == "right of" - if (abs(p.x_ - x) < abs(p.x_ + dim.wid - x)) - cur.posForward(); - } else { - // "in front of" == "left of" - if (abs(p.x_ + dim.wid - x) < abs(p.x_ - x)) - cur.posForward(); + if (insetCache.has(inset)) { + Dimension const & dim = insetCache.dim(inset); + Point p = insetCache.xy(inset); + bool const is_rtl = text_->isRTL(text_->getPar(pit)); + if (is_rtl) { + // "in front of" == "right of" + if (abs(p.x_ - x) < abs(p.x_ + dim.wid - x)) + cur.posForward(); + } else { + // "in front of" == "left of" + if (abs(p.x_ + dim.wid - x) < abs(p.x_ - x)) + cur.posForward(); + } } }