X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FTextMetrics.cpp;h=3dd052059b44e39d86c07b5eaba743f2631ed59e;hb=4ea0fd6af41beffc3eea1efcf8a0427a9d122b9c;hp=5873a281759f42eb65e1472e3b1f1c02cb186586;hpb=ae6e6b3e479b73fae40b0d7181aa0cc96cda3ddc;p=lyx.git diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 5873a28175..3dd052059b 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -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(); + } } }