macOS: handle the OS calling insertText: with a nil string

Fixes #10152
This commit is contained in:
Kovid Goyal 2026-06-15 13:36:18 +05:30
parent 65e6a127ff
commit 1dc3730782
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -2023,6 +2023,10 @@ - (NSRect)firstRectForCharacterRange:(NSRange)range
- (void)insertText:(id)string replacementRange:(NSRange)replacementRange - (void)insertText:(id)string replacementRange:(NSRange)replacementRange
{ {
if (!string) {
debug_input("\n\tinsertText: nil replacementRange: (%lu, %lu)\n", replacementRange.location, replacementRange.length);
return;
}
const char *utf8 = polymorphic_string_as_utf8(string); const char *utf8 = polymorphic_string_as_utf8(string);
debug_input("\n\tinsertText: %s replacementRange: (%lu, %lu)\n", utf8, replacementRange.location, replacementRange.length); debug_input("\n\tinsertText: %s replacementRange: (%lu, %lu)\n", utf8, replacementRange.location, replacementRange.length);
if ([self hasMarkedText] && !is_ascii_control_char(utf8[0])) { if ([self hasMarkedText] && !is_ascii_control_char(utf8[0])) {