am 4186b1d4: Merge "Stop offering "Replace..." when there are no suggestions." into mnc-dev
* commit '4186b1d4d833544f007009e437eecebb037677f2': Stop offering "Replace..." when there are no suggestions.
This commit is contained in:
@@ -1843,12 +1843,18 @@ public class Editor {
|
|||||||
}
|
}
|
||||||
if (selectionStart == selectionEnd) {
|
if (selectionStart == selectionEnd) {
|
||||||
// Spans overlap the cursor.
|
// Spans overlap the cursor.
|
||||||
return true;
|
for (int i = 0; i < suggestionSpans.length; i++) {
|
||||||
|
if (suggestionSpans[i].getSuggestions().length > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
int minSpanStart = mTextView.getText().length();
|
int minSpanStart = mTextView.getText().length();
|
||||||
int maxSpanEnd = 0;
|
int maxSpanEnd = 0;
|
||||||
int unionOfSpansCoveringSelectionStartStart = mTextView.getText().length();
|
int unionOfSpansCoveringSelectionStartStart = mTextView.getText().length();
|
||||||
int unionOfSpansCoveringSelectionStartEnd = 0;
|
int unionOfSpansCoveringSelectionStartEnd = 0;
|
||||||
|
boolean hasValidSuggestions = false;
|
||||||
for (int i = 0; i < suggestionSpans.length; i++) {
|
for (int i = 0; i < suggestionSpans.length; i++) {
|
||||||
final int spanStart = spannable.getSpanStart(suggestionSpans[i]);
|
final int spanStart = spannable.getSpanStart(suggestionSpans[i]);
|
||||||
final int spanEnd = spannable.getSpanEnd(suggestionSpans[i]);
|
final int spanEnd = spannable.getSpanEnd(suggestionSpans[i]);
|
||||||
@@ -1858,11 +1864,16 @@ public class Editor {
|
|||||||
// The span doesn't cover the current selection start point.
|
// The span doesn't cover the current selection start point.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
hasValidSuggestions =
|
||||||
|
hasValidSuggestions || suggestionSpans[i].getSuggestions().length > 0;
|
||||||
unionOfSpansCoveringSelectionStartStart =
|
unionOfSpansCoveringSelectionStartStart =
|
||||||
Math.min(unionOfSpansCoveringSelectionStartStart, spanStart);
|
Math.min(unionOfSpansCoveringSelectionStartStart, spanStart);
|
||||||
unionOfSpansCoveringSelectionStartEnd =
|
unionOfSpansCoveringSelectionStartEnd =
|
||||||
Math.max(unionOfSpansCoveringSelectionStartEnd, spanEnd);
|
Math.max(unionOfSpansCoveringSelectionStartEnd, spanEnd);
|
||||||
}
|
}
|
||||||
|
if (!hasValidSuggestions) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (unionOfSpansCoveringSelectionStartStart >= unionOfSpansCoveringSelectionStartEnd) {
|
if (unionOfSpansCoveringSelectionStartStart >= unionOfSpansCoveringSelectionStartEnd) {
|
||||||
// No spans cover the selection start point.
|
// No spans cover the selection start point.
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user