Skip to content

Commit

Permalink
Fix Edit.makeTextInfo(caret) when selection is present
Browse files Browse the repository at this point in the history
  • Loading branch information
mltony committed Apr 26, 2024
1 parent bf96860 commit 6181800
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion source/NVDAObjects/window/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import watchdog
import locationHelper
import textUtils
from comInterfaces._8CC497C9_A1DF_11CE_8098_00AA0047BE5D_0_1_0 import tomSelStartActive

selOffsetsAtLastCaretEvent=None

Expand Down Expand Up @@ -718,7 +719,11 @@ def __init__(self,obj,position,_rangeObj=None):
self._rangeObj=self.obj.ITextSelectionObject.duplicate
elif position==textInfos.POSITION_CARET:
self._rangeObj=self.obj.ITextSelectionObject.duplicate
self._rangeObj.Collapse(True)
startActive: bool = (self.obj.ITextSelectionObject.Flags & tomSelStartActive) > 0
# Notice: in the following line Collapse() method is called on ITextRange object, not on TextInfo.
# It's boolean argument has the opposite meaning from the one in TextInfo:
# True means collapse to the start, while False means collapse to the end
self._rangeObj.Collapse(startActive)
elif position==textInfos.POSITION_FIRST:
self._rangeObj=self.obj.ITextDocumentObject.range(0,0)
elif position==textInfos.POSITION_LAST:
Expand Down

0 comments on commit 6181800

Please sign in to comment.