From 994645f5d9a2f53f73c4bc471e9754d97dff13f8 Mon Sep 17 00:00:00 2001 From: Mengjuei Date: Mon, 25 Jun 2018 01:08:16 +0800 Subject: [PATCH] Fix incorrect unprintable ASCII handling (#139) When Caps Lock is on and when the character code is not printable, we should simply reject handling such character instead of absorbing it and inserting the character to the client buffer--not all apps handle those insertions. --- Source/InputMethodController.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/InputMethodController.mm b/Source/InputMethodController.mm index 5e207827..6197d5ae 100644 --- a/Source/InputMethodController.mm +++ b/Source/InputMethodController.mm @@ -593,6 +593,11 @@ public: return NO; } + // if ASCII but not printable, don't use insertText:replacementRange: as many apps don't handle non-ASCII char insertions. + if (charCode < 0x80 && !isprint(charCode)) { + return NO; + } + // when shift is pressed, don't do further processing, since it outputs capital letter anyway. NSString *popedText = [inputText lowercaseString]; [client insertText:popedText replacementRange:NSMakeRange(NSNotFound, NSNotFound)];