commit e1261817d29c4afbc36ce177cbea3114d8648ae6
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Wed Jan 6 18:49:41 2021 +0100

    fix Row::findElement when there is a Virtual element
---
 src/Row.cpp |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/Row.cpp b/src/Row.cpp
index 483094a..16ae9ae 100644
--- a/src/Row.cpp
+++ b/src/Row.cpp
@@ -626,15 +626,17 @@ Row::findElement(pos_type const pos, bool const boundary, 
double & x) const
 
        const_iterator cit = begin();
        for ( ; cit != end() ; ++cit) {
-               /** Look whether the cursor is inside the element's
-                * span. Note that it is necessary to take the
-                * boundary into account, and to accept virtual
-                * elements, which have pos == endpos.
+               /** Look whether the cursor is inside the element's span. Note
+                * that it is necessary to take the boundary into account, and
+                * to accept virtual elements, in which case the position
+                * will be before the virtual element.
                 */
-               if (pos + boundary_corr >= cit->pos
-                   && (pos + boundary_corr < cit->endpos || cit->isVirtual())) 
{
-                               x += cit->pos2x(pos);
-                               break;
+               if (cit->isVirtual() && pos + boundary_corr == cit->pos)
+                       break;
+               else if (pos + boundary_corr >= cit->pos
+                        && pos + boundary_corr < cit->endpos) {
+                       x += cit->pos2x(pos);
+                       break;
                }
                x += cit->full_width();
        }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to