1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Windows Accessibility: Fix single-character range/boundary calculation

Narrator on Windows seems to call ExpandToEnclosingUnit to find the
character immediately following the current cursor position. When
expanding a degenerate range with position `input` (used to represent
the cursor position) to a single-character range, the returned range
should start at `input` and end at `input+1`. Previously,
findTextBoundary() would always return the position before
currentPosition when searching backwards by character, so the result of
ExpandToEnclosingUnit would be off-by-one when expanding to the closest
character.
This commit is contained in:
reuk 2022-02-07 18:55:45 +00:00
parent e5255eb76c
commit 92f350e617
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -50,12 +50,12 @@ namespace AccessibilityTextHelpers
const auto numCharacters = textInterface.getTotalNumCharacters();
const auto isForwards = (direction == Direction::forwards);
auto offsetWithDirecton = [isForwards] (int input) { return isForwards ? input : -input; };
const auto offsetWithDirecton = [isForwards] (int input) { return isForwards ? input : -input; };
switch (boundary)
{
case BoundaryType::character:
return jlimit (0, numCharacters, currentPosition + offsetWithDirecton (1));
return jlimit (0, numCharacters, isForwards ? currentPosition + 1 : currentPosition);
case BoundaryType::word:
case BoundaryType::line: