Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getting offsets from points in edit controls when offset numbers exceed 16 bits #8397

Merged
merged 5 commits into from Jul 18, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion source/NVDAObjects/window/edit.py
Expand Up @@ -193,7 +193,19 @@ def _getOffsetFromPoint(self,x,y):
winKernel.virtualFreeEx(processHandle,internalP,0,winKernel.MEM_RELEASE)
else:
p=(x-left)+((y-top)<<16)
offset=watchdog.cancellableSendMessage(self.obj.windowHandle,winUser.EM_CHARFROMPOS,0,p)&0xffff
res=watchdog.cancellableSendMessage(self.obj.windowHandle,winUser.EM_CHARFROMPOS,0,p)
offset=winUser.LOWORD(res)
lineNum=winUser.HIWORD(res)
if offset==0xFFFF and lineNum==0xFFFF:
raise LookupError("Point outside client aria")
if self._getStoryLength() > 0xFFFF:
# Offsets are 16 bits, therefore for large documents, we need to make sure that the correct offset is returned.
# We can calculate this by using the line number.
lineStart=watchdog.cancellableSendMessage(self.obj.windowHandle,winUser.EM_LINEINDEX,lineNum,0)
lineStartLW = winUser.LOWORD(lineStart)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is contained in the LOWORD? Could the variable name make this clear?

if lineStartLW > offset:
offset+= 0x10000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after =

offset = (offset - lineStartLW) + lineStart
return offset

def _getCharFormat(self,offset):
Expand Down