Skip to content

Commit b235bf9

Browse files
committed
Close #76. dont complete without enough entered
1 parent 9ad38d7 commit b235bf9

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

library/src/main/java/com/tokenautocomplete/TokenCompleteTextView.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ public boolean enoughToFilter() {
402402

403403
@Override
404404
public void performCompletion() {
405-
if (getListSelection() == ListView.INVALID_POSITION) {
405+
if (getListSelection() == ListView.INVALID_POSITION && enoughToFilter()) {
406406
Object bestGuess;
407407
if (getAdapter().getCount() > 0 && performBestGuess) {
408408
bestGuess = getAdapter().getItem(0);
@@ -428,10 +428,8 @@ public InputConnection onCreateInputConnection(@NonNull EditorInfo outAttrs) {
428428
* Use IME_NEXT if you want to create a token and go to the next field
429429
*/
430430
private void handleDone() {
431-
// If there is enough text to filter, attempt to complete the token
432-
if (enoughToFilter()) {
433-
performCompletion();
434-
}
431+
// Attempt to complete the current token token
432+
performCompletion();
435433

436434
// Hide the keyboard
437435
InputMethodManager imm = (InputMethodManager)getContext().getSystemService(
@@ -671,7 +669,7 @@ public void onFocusChanged(boolean hasFocus, int direction, Rect previous) {
671669
super.onFocusChanged(hasFocus, direction, previous);
672670

673671
// See if the user left any unfinished tokens and finish them
674-
if(!hasFocus && enoughToFilter()) performCompletion();
672+
if(!hasFocus) performCompletion();
675673

676674
// Collapse the view to a single line
677675
if(allowCollapse) performCollapse(hasFocus);

0 commit comments

Comments
 (0)