Skip to content

Commit

Permalink
Fixes #17418)
Browse files Browse the repository at this point in the history
Summary of the issue:
Nvda crashes when selecting whole text in specific source files in Android Studio and IntelliJ Idea

Description of user facing changes
NVDA should no longer crash.

Description of development approach
Java Access Bridge has a buffer limit of 10240 characters for the text. If the text is too large to fit on this buffer size, NVDA will split the calls to take the buffer size in account.
  • Loading branch information
thgcode committed Jan 10, 2025
1 parent e06f2b8 commit 6973d4d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion source/JABHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def getAccessibleTextSelectionInfo(self):
bridgeDll.getAccessibleTextSelectionInfo(self.vmID, self.accContext, byref(textSelectionInfo))
return textSelectionInfo

def getAccessibleTextRange(self, start, end):
def _javaGetAccessibleTextRange(self, start, end):
length = (end + 1) - start
if length <= 0:
return ""
Expand All @@ -656,6 +656,24 @@ def getAccessibleTextRange(self, start, end):
bridgeDll.getAccessibleTextRange(self.vmID, self.accContext, start, end, buf, length)
return textUtils.getTextFromRawBytes(buf.raw, numChars=length, encoding=textUtils.WCHAR_ENCODING)

# Constant gotten from AccessBridgePackages.h,
# minus one to accommodate the null character
MAX_BUFFER_SIZE = 10239

def getAccessibleTextRange(self, start, end):
length = (end + 1) - start
if length <= 0:
return ""

text = []
while start <= end:
bufferSize = min(self.MAX_BUFFER_SIZE, length)
text.append(self._javaGetAccessibleTextRange(start, start + bufferSize - 1))
start += bufferSize
length = (end + 1) - start

return "".join(text)

def getAccessibleTextLineBounds(self, index):
index = max(index, 0)
log.debug("lineBounds: index %s" % index)
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Prefix matching on command line flags, e.g. using `--di` for `--disable-addons`

### Bug Fixes

* NVDA will no longer crash when selecting whole text in specific source files in Android Studio or IntelliJ Idea. (#17418, @thgcode)
* Math reading has been fixed for some web elements.
Specifically, MathML inside of span and other elements that have the attribute `role="math"`. (#15058)
* Native support for the Dot Pad tactile graphics device from Dot Inc as a multiline braille display. (#17007)
Expand Down

0 comments on commit 6973d4d

Please sign in to comment.