From bda9145aae3e50f1304e8faa2c7be0ce65feb4a5 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Tue, 14 Jan 2020 19:07:55 +0800 Subject: [PATCH] Fixes IME input backspace on macOS --- platform/osx/os_osx.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 2b002d3b5dd..6a214b8669b 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -479,7 +479,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; } - (NSRange)markedRange { - return (markedText.length > 0) ? NSMakeRange(0, markedText.length - 1) : kEmptyRange; + return NSMakeRange(0, markedText.length); } - (NSRange)selectedRange { @@ -492,6 +492,10 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; } else { [markedText initWithString:aString]; } + if (markedText.length == 0) { + [self unmarkText]; + return; + } if (OS_OSX::singleton->im_active) { imeInputEventInProgress = true; OS_OSX::singleton->im_text.parse_utf8([[markedText mutableString] UTF8String]);