From 8c03723da745f44a05b2bc234d4651474071345d Mon Sep 17 00:00:00 2001 From: Gilles Debunne Date: Mon, 4 Oct 2010 16:03:52 -0700 Subject: [PATCH] DO NOT MERGE. Select word no longer selects spaces between words. Bug 3000870 This feature was useful to paste between two words. To do this, all you have to do now in to first position the cursor between the words, and then long pressing anywhere to get the pop-up menu with paste. Not merged into HC since the paste story in HC still has to be determined. Change-Id: Iea8d87e09b7ad43658ec5526110e609b9735c27a --- core/java/android/widget/TextView.java | 45 +------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 5802704f4af79..6522de02a3962 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -7237,50 +7237,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener ((SelectionModifierCursorController) mSelectionModifierCursorController); int minOffset = selectionModifierCursorController.getMinTouchOffset(); int maxOffset = selectionModifierCursorController.getMaxTouchOffset(); - - if (minOffset == maxOffset) { - int offset = Math.max(0, Math.min(minOffset, mTransformed.length())); - - // Tolerance, number of charaters around tapped position - final int range = 1; - final int max = mTransformed.length() - 1; - - // 'Smart' word selection: detect position between words - for (int i = -range; i <= range; i++) { - int index = offset + i; - if (index >= 0 && index <= max) { - if (Character.isSpaceChar(mTransformed.charAt(index))) { - // Select current space - selectionStart = index; - selectionEnd = selectionStart + 1; - - // Extend selection to maximum space range - while (selectionStart > 0 && - Character.isSpaceChar(mTransformed.charAt(selectionStart - 1))) { - selectionStart--; - } - while (selectionEnd < max && - Character.isSpaceChar(mTransformed.charAt(selectionEnd))) { - selectionEnd++; - } - - Selection.setSelection((Spannable) mText, selectionStart, selectionEnd); - return; - } - } - } - - // 'Smart' word selection: detect position at beginning or end of text. - if (offset <= range) { - Selection.setSelection((Spannable) mText, 0, 0); - return; - } - if (offset >= (max - range)) { - Selection.setSelection((Spannable) mText, max + 1, max + 1); - return; - } - } - + long wordLimits = getWordLimitsAt(minOffset); if (wordLimits >= 0) { selectionStart = (int) (wordLimits >>> 32);