From 92f350e617a4f93fba18bcb0cd88b47d2eb3d8e3 Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 7 Feb 2022 18:55:45 +0000 Subject: [PATCH] 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. --- .../native/accessibility/juce_AccessibilityTextHelpers.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers.h b/modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers.h index 3c74b331e7..a519fd323d 100644 --- a/modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers.h +++ b/modules/juce_gui_basics/native/accessibility/juce_AccessibilityTextHelpers.h @@ -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: