Commit 990dbe7e authored by Sidney San Martín's avatar Sidney San Martín Committed by Commit Bot

[Mac] Fix automatic period insertion after a double space

Issue: When "Add period with double-space" is turned on in System
Preferences, typing two spaces after a word inserted a space, a period,
then a second space. The period should replace the first space instead.

It turned out that, since a key event is being handled at the time of
the replacement, insertText:replacementRange: took a path that didn't
consider replacementRange, and the period just got appended before the
second space. The fix avoids the key press path when a replacement range
is specified.

Bug: 752640
Change-Id: Ia051e04f87345cd12bbd3438cf351cdc649149c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1933408Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Sidney San Martín <sdy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719262}
parent 5cb982b8
...@@ -2029,7 +2029,7 @@ extern NSString* NSTextInputReplacementRangeAttributeName; ...@@ -2029,7 +2029,7 @@ extern NSString* NSTextInputReplacementRangeAttributeName;
// the full web content. // the full web content.
BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]];
NSString* im_text = isAttributedString ? [string string] : string; NSString* im_text = isAttributedString ? [string string] : string;
if (handlingKeyDown_) { if (handlingKeyDown_ && replacementRange.location == NSNotFound) {
textToBeInserted_.append(base::SysNSStringToUTF16(im_text)); textToBeInserted_.append(base::SysNSStringToUTF16(im_text));
shouldRequestTextSubstitutions_ = YES; shouldRequestTextSubstitutions_ = YES;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment