]> git.lyx.org Git - features.git/commit
Make TextMetrics::editXY more robust
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 27 May 2014 13:14:14 +0000 (15:14 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 4 Jun 2014 10:17:01 +0000 (12:17 +0200)
commitd4faf127d74643ce10a1a5240ea02601336e48fe
treeb63760ca5ad6de093daf0415cdfc33ee50539367
parent8669088b7119d559858aa6c8bc3f7e03421d6255
Make TextMetrics::editXY more robust

This fixes a crash in examples/fa/splash.lyx when selecting text
representing menu entries. This happens because menu names are in LTR
English, while the inset itself is in RTL.

The problem is that the current code relies on the fact that
 1. getColumnNearX and checkInsetHit share the same idea about cursor
    position.
 2. pos and pos + 1 are in general consecutive on screen.

It seems that 1. is wrong here (for reasons I did not try to
understand); the second assumption is definitely false with
bi-directional text. This makes editXY very fragile.

The new code should be more robust in this respect. The logic is:
 * if checkInsetHit finds an inset, use its position,
 * otherwise, ask getColumnNearX for the cursor position.

Fixes: #9142
src/TextMetrics.cpp
src/TextMetrics.h
status.21x