Loading core/java/android/view/inputmethod/BaseInputConnection.java +20 −3 Original line number Original line Diff line number Diff line Loading @@ -211,6 +211,10 @@ public class BaseInputConnection implements InputConnection { * If this is greater than the number of existing characters between the cursor and * If this is greater than the number of existing characters between the cursor and * the end of the text, then this method does not fail but deletes all the characters in * the end of the text, then this method does not fail but deletes all the characters in * that range. * that range. * * @return {@code true} when selected text is deleted, {@code false} when either the * selection is invalid or not yet attached (i.e. selection start or end is -1), * or the editable text is {@code null}. */ */ public boolean deleteSurroundingText(int beforeLength, int afterLength) { public boolean deleteSurroundingText(int beforeLength, int afterLength) { if (DEBUG) Log.v(TAG, "deleteSurroundingText " + beforeLength if (DEBUG) Log.v(TAG, "deleteSurroundingText " + beforeLength Loading @@ -229,6 +233,12 @@ public class BaseInputConnection implements InputConnection { b = tmp; b = tmp; } } // Skip when the selection is not yet attached. if (a == -1 || b == -1) { endBatchEdit(); return false; } // Ignore the composing text. // Ignore the composing text. int ca = getComposingSpanStart(content); int ca = getComposingSpanStart(content); int cb = getComposingSpanEnd(content); int cb = getComposingSpanEnd(content); Loading @@ -247,8 +257,12 @@ public class BaseInputConnection implements InputConnection { if (beforeLength > 0) { if (beforeLength > 0) { int start = a - beforeLength; int start = a - beforeLength; if (start < 0) start = 0; if (start < 0) start = 0; final int numDeleteBefore = a - start; if (a >= 0 && numDeleteBefore > 0) { content.delete(start, a); content.delete(start, a); deleted = a - start; deleted = numDeleteBefore; } } } if (afterLength > 0) { if (afterLength > 0) { Loading @@ -257,8 +271,11 @@ public class BaseInputConnection implements InputConnection { int end = b + afterLength; int end = b + afterLength; if (end > content.length()) end = content.length(); if (end > content.length()) end = content.length(); final int numDeleteAfter = end - b; if (b >= 0 && numDeleteAfter > 0) { content.delete(b, end); content.delete(b, end); } } } endBatchEdit(); endBatchEdit(); Loading Loading
core/java/android/view/inputmethod/BaseInputConnection.java +20 −3 Original line number Original line Diff line number Diff line Loading @@ -211,6 +211,10 @@ public class BaseInputConnection implements InputConnection { * If this is greater than the number of existing characters between the cursor and * If this is greater than the number of existing characters between the cursor and * the end of the text, then this method does not fail but deletes all the characters in * the end of the text, then this method does not fail but deletes all the characters in * that range. * that range. * * @return {@code true} when selected text is deleted, {@code false} when either the * selection is invalid or not yet attached (i.e. selection start or end is -1), * or the editable text is {@code null}. */ */ public boolean deleteSurroundingText(int beforeLength, int afterLength) { public boolean deleteSurroundingText(int beforeLength, int afterLength) { if (DEBUG) Log.v(TAG, "deleteSurroundingText " + beforeLength if (DEBUG) Log.v(TAG, "deleteSurroundingText " + beforeLength Loading @@ -229,6 +233,12 @@ public class BaseInputConnection implements InputConnection { b = tmp; b = tmp; } } // Skip when the selection is not yet attached. if (a == -1 || b == -1) { endBatchEdit(); return false; } // Ignore the composing text. // Ignore the composing text. int ca = getComposingSpanStart(content); int ca = getComposingSpanStart(content); int cb = getComposingSpanEnd(content); int cb = getComposingSpanEnd(content); Loading @@ -247,8 +257,12 @@ public class BaseInputConnection implements InputConnection { if (beforeLength > 0) { if (beforeLength > 0) { int start = a - beforeLength; int start = a - beforeLength; if (start < 0) start = 0; if (start < 0) start = 0; final int numDeleteBefore = a - start; if (a >= 0 && numDeleteBefore > 0) { content.delete(start, a); content.delete(start, a); deleted = a - start; deleted = numDeleteBefore; } } } if (afterLength > 0) { if (afterLength > 0) { Loading @@ -257,8 +271,11 @@ public class BaseInputConnection implements InputConnection { int end = b + afterLength; int end = b + afterLength; if (end > content.length()) end = content.length(); if (end > content.length()) end = content.length(); final int numDeleteAfter = end - b; if (b >= 0 && numDeleteAfter > 0) { content.delete(b, end); content.delete(b, end); } } } endBatchEdit(); endBatchEdit(); Loading