From 1bb18fc127a1b43a761f955e6f2dcbb283d947ee Mon Sep 17 00:00:00 2001 From: Anastassia Pellja Date: Wed, 17 Jun 2026 14:53:08 +0300 Subject: [PATCH] fix character replacement when selecting with left/right arrow keys --- native/Avalonia.Native/src/OSX/AvnView.mm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/native/Avalonia.Native/src/OSX/AvnView.mm b/native/Avalonia.Native/src/OSX/AvnView.mm index 1fc95390e0..7381e046ad 100644 --- a/native/Avalonia.Native/src/OSX/AvnView.mm +++ b/native/Avalonia.Native/src/OSX/AvnView.mm @@ -877,6 +877,19 @@ static void ConvertTilt(NSPoint tilt, float* xTilt, float* yTilt) parent->InputMethod->Client->SelectInSurroundingText(start, end); } } + // If special character is selected with left/right arrow keys + // macOS reports NSNotFound instead of a replacement range. + // If there is a single marked character, select it so the committed + // character replaces the preview character. + // Only handle marked range of 1 character to avoid affecting IME. + if (replacementRange.location == NSNotFound && + _markedRange.length == 1 && + parent->InputMethod->IsActive()) + { + int start = (int)_markedRange.location; + int end = start + 1; + parent->InputMethod->Client->SelectInSurroundingText(start, end); + } [self unmarkText];