From f6b876ef1f4c1621dc4822ace7673e45dd30ea0b 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. Backport of changeset 7171:d07ee885f2dd, but translated to C++11. --- cocoa/ScintillaCocoa.mm | 13 ++++++++++++- doc/ScintillaHistory.html | 13 +++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index ec78479b9..8d061205a 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -2284,7 +2284,18 @@ ptrdiff_t ScintillaCocoa::InsertText(NSString *input) { 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 sv = encoded; + while (sv.length()) { + const unsigned char leadByte = sv[0]; + const unsigned int bytesInCharacter = UTF8BytesOfLead[leadByte]; + AddCharUTF(sv.c_str(), bytesInCharacter, false); + sv = sv.substr(bytesInCharacter, sv.length()); + } + } else { + AddCharUTF(encoded.c_str(), static_cast(encoded.length()), false); + } } return encoded.length(); } diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 6d67c2f13..8b6a1d43c 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -542,6 +542,19 @@

Release 3.10.1

+
    +
  • + Released 31 October 2018. +
  • +
  • + 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. +
  • +
+

+ Release 3.10.1 +

  • Released 31 October 2018. -- cgit v1.2.3