Fixes IME input backspace on macOS

This commit is contained in:
Haoyu Qiu 2020-01-14 19:07:55 +08:00
parent dbbfade584
commit bda9145aae
1 changed files with 5 additions and 1 deletions

View File

@ -479,7 +479,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
} }
- (NSRange)markedRange { - (NSRange)markedRange {
return (markedText.length > 0) ? NSMakeRange(0, markedText.length - 1) : kEmptyRange; return NSMakeRange(0, markedText.length);
} }
- (NSRange)selectedRange { - (NSRange)selectedRange {
@ -492,6 +492,10 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
} else { } else {
[markedText initWithString:aString]; [markedText initWithString:aString];
} }
if (markedText.length == 0) {
[self unmarkText];
return;
}
if (OS_OSX::singleton->im_active) { if (OS_OSX::singleton->im_active) {
imeInputEventInProgress = true; imeInputEventInProgress = true;
OS_OSX::singleton->im_text.parse_utf8([[markedText mutableString] UTF8String]); OS_OSX::singleton->im_text.parse_utf8([[markedText mutableString] UTF8String]);