fix Row::findElement when there is a Virtual element

This commit is contained in:
Jean-Marc Lasgouttes 2021-01-06 18:49:41 +01:00
parent 51b37cd4d8
commit e1261817d2

View File

@ -626,15 +626,17 @@ Row::findElement(pos_type const pos, bool const boundary, double & x) const
const_iterator cit = begin(); const_iterator cit = begin();
for ( ; cit != end() ; ++cit) { for ( ; cit != end() ; ++cit) {
/** Look whether the cursor is inside the element's /** Look whether the cursor is inside the element's span. Note
* span. Note that it is necessary to take the * that it is necessary to take the boundary into account, and
* boundary into account, and to accept virtual * to accept virtual elements, in which case the position
* elements, which have pos == endpos. * will be before the virtual element.
*/ */
if (pos + boundary_corr >= cit->pos if (cit->isVirtual() && pos + boundary_corr == cit->pos)
&& (pos + boundary_corr < cit->endpos || cit->isVirtual())) { break;
x += cit->pos2x(pos); else if (pos + boundary_corr >= cit->pos
break; && pos + boundary_corr < cit->endpos) {
x += cit->pos2x(pos);
break;
} }
x += cit->full_width(); x += cit->full_width();
} }