From 4f473d04af589238a0485dc864184cec2c82fe67 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Tue, 7 Aug 2012 15:47:05 -0700 Subject: [PATCH] Bug 781038 - Part 1: Span and select the Editable's actual length. r=blassey --- mobile/android/base/GeckoInputConnection.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mobile/android/base/GeckoInputConnection.java b/mobile/android/base/GeckoInputConnection.java index 1557fd91e5e..45f866a4483 100644 --- a/mobile/android/base/GeckoInputConnection.java +++ b/mobile/android/base/GeckoInputConnection.java @@ -1149,16 +1149,19 @@ class GeckoInputConnection } private void setEditable(String contents) { + int prevLength = mEditable.length(); mEditable.removeSpan(this); - mEditable.replace(0, mEditable.length(), contents); - mEditable.setSpan(this, 0, contents.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); - Selection.setSelection(mEditable, contents.length()); + mEditable.replace(0, prevLength, contents); + int newLength = mEditable.length(); + mEditable.setSpan(this, 0, newLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE); + Selection.setSelection(mEditable, newLength); } private void initEditable(String contents) { mEditable = mEditableFactory.newEditable(contents); - mEditable.setSpan(this, 0, contents.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); - Selection.setSelection(mEditable, contents.length()); + int newLength = mEditable.length(); + mEditable.setSpan(this, 0, newLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE); + Selection.setSelection(mEditable, newLength); } protected final boolean hasCompositionString() {