commit 22edb3df96e78cf10aa94e0f2d9f6f6697534786
Author: Guillaume Munch <[email protected]>
Date: Fri Mar 10 23:20:29 2017 +0100
Preventive fix inspired from ~
---
src/TextMetrics.cpp | 27 ++++++++++++++++-----------
1 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 5873a28..3dd0520 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();
+ }
}
}