Skip to content

Commit 5b92a45

Browse files
Gilles DebunneAndroid (Google) Code Review
authored andcommitted
Merge "Bug 5254884: suggestions are no logner copied in the clipboard"
2 parents 67ed574 + cf68fee commit 5b92a45

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

core/java/android/widget/TextView.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9192,19 +9192,23 @@ public boolean onTextContextMenuItem(int id) {
91929192
return true;
91939193

91949194
case ID_CUT:
9195-
setPrimaryClip(ClipData.newPlainText(null, mTransformed.subSequence(min, max)));
9195+
setPrimaryClip(ClipData.newPlainText(null, getTransformedText(min, max)));
91969196
((Editable) mText).delete(min, max);
91979197
stopSelectionActionMode();
91989198
return true;
91999199

92009200
case ID_COPY:
9201-
setPrimaryClip(ClipData.newPlainText(null, mTransformed.subSequence(min, max)));
9201+
setPrimaryClip(ClipData.newPlainText(null, getTransformedText(min, max)));
92029202
stopSelectionActionMode();
92039203
return true;
92049204
}
92059205
return false;
92069206
}
92079207

9208+
private CharSequence getTransformedText(int start, int end) {
9209+
return removeSuggestionSpans(mTransformed.subSequence(start, end));
9210+
}
9211+
92089212
/**
92099213
* Prepare text so that there are not zero or two spaces at beginning and end of region defined
92109214
* by [min, max] when replacing this region by paste.
@@ -9321,7 +9325,7 @@ public boolean performLongClick() {
93219325
// Start a drag
93229326
final int start = getSelectionStart();
93239327
final int end = getSelectionEnd();
9324-
CharSequence selectedText = mTransformed.subSequence(start, end);
9328+
CharSequence selectedText = getTransformedText(start, end);
93259329
ClipData data = ClipData.newPlainText(null, selectedText);
93269330
DragLocalState localState = new DragLocalState(this, start, end);
93279331
startDrag(data, getTextThumbnailBuilder(selectedText), localState, 0);

0 commit comments

Comments
 (0)