aboutsummaryrefslogtreecommitdiffhomepage
path: root/cocoa
diff options
context:
space:
mode:
authorNeil Hodgson <nyamatongwe@gmail.com>2018-11-20 12:14:54 +1100
committerNeil Hodgson <nyamatongwe@gmail.com>2018-11-20 12:14:54 +1100
commitf6b876ef1f4c1621dc4822ace7673e45dd30ea0b (patch)
tree5454dd8a69e854f94eb6ef9a2bd9ccab2509f412 /cocoa
parent134b65b6aed960ebd5d74baa6d39bf7ec06d66ac (diff)
downloadscintilla-mirror-f6b876ef1f4c1621dc4822ace7673e45dd30ea0b.tar.gz
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.
Diffstat (limited to 'cocoa')
-rw-r--r--cocoa/ScintillaCocoa.mm13
1 files changed, 12 insertions, 1 deletions
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<unsigned int>(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<unsigned int>(encoded.length()), false);
+ }
}
return encoded.length();
}