Small code cleanup

Change-Id: I7075d85f745c3b186e6d06086b9fcd54e7459feb
This commit is contained in:
Ken Wakasa 2011-07-13 12:00:06 +09:00
parent 656a35f9df
commit 84cb23a789

View file

@ -1803,19 +1803,18 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final InputConnection ic = getCurrentInputConnection(); final InputConnection ic = getCurrentInputConnection();
final CharSequence punctuation = ic.getTextBeforeCursor(1, 0); final CharSequence punctuation = ic.getTextBeforeCursor(1, 0);
if (deleteChar) ic.deleteSurroundingText(1, 0); if (deleteChar) ic.deleteSurroundingText(1, 0);
int toDelete = mCommittedLength; final CharSequence textToTheLeft = ic.getTextBeforeCursor(mCommittedLength, 0);
final CharSequence toTheLeft = ic.getTextBeforeCursor(mCommittedLength, 0); final int toDeleteLength = (!TextUtils.isEmpty(textToTheLeft)
if (!TextUtils.isEmpty(toTheLeft) && mSettingsValues.isWordSeparator(toTheLeft.charAt(0)))
&& mSettingsValues.isWordSeparator(toTheLeft.charAt(0))) { ? mCommittedLength - 1 : mCommittedLength;
toDelete--; ic.deleteSurroundingText(toDeleteLength, 0);
}
ic.deleteSurroundingText(toDelete, 0);
// Re-insert punctuation only when the deleted character was word separator and the // Re-insert punctuation only when the deleted character was word separator and the
// composing text wasn't equal to the auto-corrected text. // composing text wasn't equal to the auto-corrected text.
if (deleteChar if (deleteChar
&& !TextUtils.isEmpty(punctuation) && !TextUtils.isEmpty(punctuation)
&& mSettingsValues.isWordSeparator(punctuation.charAt(0)) && mSettingsValues.isWordSeparator(punctuation.charAt(0))
&& !TextUtils.equals(mComposingStringBuilder, toTheLeft)) { && !TextUtils.equals(mComposingStringBuilder, textToTheLeft)) {
ic.commitText(mComposingStringBuilder, 1); ic.commitText(mComposingStringBuilder, 1);
TextEntryState.acceptedTyped(mComposingStringBuilder); TextEntryState.acceptedTyped(mComposingStringBuilder);
ic.commitText(punctuation, 1); ic.commitText(punctuation, 1);