From e6010657a470a0575a7be23e730b6e9867f9f26c Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Tue, 20 Nov 2018 12:14:54 +1100 Subject: Bug [#2061]. Fix a crash that occurred when entering a dead key diacritic then a character that can not take that diacritic, such as option+e (acute accent) followed by g. --- cocoa/ScintillaCocoa.mm | 13 ++++++++++++- doc/ScintillaHistory.html | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index 1338a66fa..9a7125023 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -2179,7 +2179,18 @@ ptrdiff_t ScintillaCocoa::InsertText(NSString *input) { std::string encoded = EncodedBytesString((__bridge CFStringRef)input, encoding); if (encoded.length() > 0) { - AddCharUTF(encoded.c_str(), static_cast(encoded.length()), false); + if (encoding == kCFStringEncodingUTF8) { + // There may be multiple characters in input so loop over them + std::string_view sv = encoded; + while (sv.length()) { + const unsigned char leadByte = sv[0]; + const unsigned int bytesInCharacter = UTF8BytesOfLead[leadByte]; + AddCharUTF(sv.data(), bytesInCharacter, false); + sv.remove_prefix(bytesInCharacter); + } + } else { + AddCharUTF(encoded.c_str(), static_cast(encoded.length()), false); + } } return encoded.length(); } diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 9f2129154..55b23216a 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -564,6 +564,11 @@ Updated case conversion and character categories to Unicode 11.
  • + On Cocoa, fix a crash that occurred when entering a dead key diacritic then a character + that can not take that diacritic, such as option+e (acute accent) followed by g. + Bug #2061. +
  • +
  • On Cocoa, use dark info bar background when system is set to Dark Appearance. Bug #2055.
  • -- cgit v1.2.3