@@ -99,7 +99,7 @@ def __init__(self, obj, position):
9999 # The caret is at the end of an inline object.
100100 # This will report "blank", but we want to report the character just after the caret.
101101 try :
102- caretTi , caretObj = self ._findNextContent (caretTi )
102+ caretTi , caretObj = self ._findNextContent (caretTi , limitToInline = True )
103103 except LookupError :
104104 pass
105105 self ._start = self ._end = caretTi
@@ -513,7 +513,7 @@ def expand(self, unit):
513513 self ._end = end
514514 self ._endObj = endObj
515515
516- def _findNextContent (self , origin , moveBack = False ):
516+ def _findNextContent (self , origin , moveBack = False , limitToInline = False ):
517517 if isinstance (origin , textInfos .TextInfo ):
518518 ti = origin
519519 obj = ti .obj
@@ -529,6 +529,12 @@ def _findNextContent(self, origin, moveBack=False):
529529 if obj == self .obj :
530530 # We're at the root. Don't go any further.
531531 raise LookupError
532+ if limitToInline :
533+ if obj .IA2Attributes .get ('display' ) != 'inline' :
534+ # The caller requested to limit to inline objects.
535+ # As this container is not inline,
536+ # We cannot go above this container.
537+ raise LookupError
532538 ti = self ._getEmbedding (obj )
533539 if not ti :
534540 raise LookupError
0 commit comments