From 15b0984b237ba7c81aece4e7414b6c568acabe59 Mon Sep 17 00:00:00 2001 From: serso Date: Mon, 16 May 2016 20:39:02 +0200 Subject: [PATCH] Use INCLUSIVE_EXCLUSIVE to support 0-size numbers --- .../java/org/solovyev/android/calculator/NumberBuilder.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/solovyev/android/calculator/NumberBuilder.java b/app/src/main/java/org/solovyev/android/calculator/NumberBuilder.java index 0a241a75..401dceb0 100644 --- a/app/src/main/java/org/solovyev/android/calculator/NumberBuilder.java +++ b/app/src/main/java/org/solovyev/android/calculator/NumberBuilder.java @@ -52,6 +52,7 @@ public class NumberBuilder extends BaseNumberBuilder { @Nonnull NumeralBase nb, @Nonnull final MathEngine engine) { if (oldNumber == null) { + sb.setSpan(new NumberSpan(nb), sb.length(), sb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); return 0; } // in any case remove old number from text @@ -59,9 +60,7 @@ public class NumberBuilder extends BaseNumberBuilder { sb.delete(sb.length() - oldNumberLength, sb.length()); final SpannableString newNumber = new SpannableString(engine.format(oldNumber, nb)); - if (newNumber.length() >= 1) { - newNumber.setSpan(new NumberSpan(nb), 0, newNumber.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - } + newNumber.setSpan(new NumberSpan(nb), 0, newNumber.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); sb.append(newNumber); // offset between old number and new number return newNumber.length() - oldNumberLength;