commit 7ca7873112314963c3a43987f32484749ec3af58
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Thu Jun 8 11:35:05 2017 +0200
Fix bad cursor positioning when entering an inset
The test added at 359aef92 was incorrect. Actually, Inset::editXY
returns the inset when it is edited and also when it is not, which
can be confusing. So if we are unlucky and the slices positions in the
text area and in the inner inset match, the code below triggers and
many bad things can happen.
editXY() should probably have a documented way to indicate whether the
cursor has entered the inset, although the test used right now is
probably OK. The inset value is useful mainly for context menus or
tasks that need to know which inset the (x, y) coordinates
point to.
Note finally that the documentation of TextMetrics::editXY is
incorrect concerning the return value. It will return a non-null value
if the cursor is on a not editable inset.
Fixes #10691.
---
src/TextMetrics.cpp | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 1f0c62b..f38c78d 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -1379,7 +1379,9 @@ Inset * TextMetrics::editXY(Cursor & cur, int x, int y,
// Try to descend recursively inside the inset.
Inset * edited = inset->editXY(cur, x, y);
- if (edited == inset && cur.pos() == it->pos) {
+ // FIXME: it is not clear that the test on position is needed
+ // Remove it if/when semantics of editXY is clarified
+ if (cur.text() == text_ && cur.pos() == it->pos) {
// non-editable inset, set cursor after the inset if x is
// nearer to that position (bug 9628)
bool bound = false; // is modified by getPosNearX