@@ -65,8 +65,8 @@ def _getEmbedded(obj, offset) -> typing.Optional[IAccessible]:
6565
6666class MozillaCompoundTextInfo (CompoundTextInfo ):
6767
68- def _getControlFieldForObject (self , obj , ignoreEditableText = True ):
69- controlField = super ()._getControlFieldForObject (obj , ignoreEditableText = ignoreEditableText )
68+ def _getControlFieldForObject (self , obj ):
69+ controlField = super ()._getControlFieldForObject (obj )
7070 if controlField is None :
7171 return None
7272 # Set the uniqueID of the controlField if we can get one
@@ -267,7 +267,13 @@ def _iterRecursiveText(self, ti: offsets.OffsetsTextInfo, controlStack, formatCo
267267 elif isinstance (item , int ): # Embedded object.
268268 embedded : typing .Optional [IAccessible ] = _getEmbedded (ti .obj , item )
269269 notText = _getRawTextInfo (embedded ) is NVDAObjectTextInfo
270- if controlStack is not None :
270+ if (
271+ controlStack is not None
272+ and not (
273+ self ._isObjectEditableText (embedded )
274+ or self ._isNamedlinkDestination (embedded )
275+ )
276+ ):
271277 controlField = self ._getControlFieldForObject (embedded )
272278 controlStack .append (controlField )
273279 if controlField :
@@ -313,16 +319,19 @@ def _getText(self, withFields, formatConfig=None):
313319 ti = self ._start
314320 cannotBeStart = False
315321 while obj and obj != rootObj :
316- field = self ._getControlFieldForObject (obj )
317- if field :
322+ if not (
323+ self ._isObjectEditableText (obj )
324+ or self ._isNamedlinkDestination (obj )
325+ ):
326+ field = self ._getControlFieldForObject (obj )
318327 if ti ._startOffset == 0 :
319328 if not cannotBeStart :
320329 field ["_startOfNode" ] = True
321330 else :
322331 # We're not at the start of this object, which also means we're not at the start of any ancestors.
323332 cannotBeStart = True
324333 fields .insert (0 , textInfos .FieldCommand ("controlStart" , field ))
325- controlStack .insert (0 , field )
334+ controlStack .insert (0 , field )
326335 ti = self ._getEmbedding (obj )
327336 if not ti :
328337 log .debugWarning (
@@ -341,7 +350,7 @@ def _getText(self, withFields, formatConfig=None):
341350 # (We already handled collapsed above.)
342351 return fields
343352 obj = self ._startObj
344- while fields [- 1 ] is not None :
353+ while fields [- 1 ] is not None and controlStack :
345354 # The end hasn't yet been reached, which means it isn't a descendant of obj.
346355 # Therefore, continue from where obj was embedded.
347356 if withFields :
@@ -354,10 +363,9 @@ def _getText(self, withFields, formatConfig=None):
354363 # range is invalid, so just return nothing.
355364 log .debugWarning ("Tried to walk up past the root. Objects probably dead." )
356365 return []
357- if field :
358- # This object had a control field.
359- field ["_endOfNode" ] = True
360- fields .append (textInfos .FieldCommand ("controlEnd" , None ))
366+ # This object had a control field.
367+ field ["_endOfNode" ] = True
368+ fields .append (textInfos .FieldCommand ("controlEnd" , None ))
361369 ti = self ._getEmbedding (obj )
362370 if not ti :
363371 log .debugWarning (
@@ -377,13 +385,11 @@ def _getText(self, withFields, formatConfig=None):
377385 # Determine whether the range covers the end of any ancestors of endObj.
378386 obj = self ._endObj
379387 ti = self ._end
380- while obj and obj != rootObj :
388+ while obj and obj != rootObj and controlStack :
381389 field = controlStack .pop ()
382- if field :
383- fields .append (textInfos .FieldCommand ("controlEnd" , None ))
390+ fields .append (textInfos .FieldCommand ("controlEnd" , None ))
384391 if ti .compareEndPoints (self ._makeRawTextInfo (obj , textInfos .POSITION_ALL ), "endToEnd" ) == 0 :
385- if field :
386- field ["_endOfNode" ] = True
392+ field ["_endOfNode" ] = True
387393 else :
388394 # We're not at the end of this object, which also means we're not at the end of any ancestors.
389395 break
0 commit comments