Ignore:
Timestamp:
2011-02-11T23:17:33+01:00 (13 years ago)
Author:
bastiK
Message:

fix #5927 - Auto-complete is partially broken (patch by ax)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java

    r3866 r3891  
    8585            }
    8686
    87             // the string being inserted might be a "full" string from the list
    88             // of valid completions (instanceof AutoCompletionListItem), or a
    89             // "partial" string being typed (instanceof String).
    90             Object item = comboBox.getSelectedItem();
    91             if (item != null && (item instanceof String || !curText.equals(((AutoCompletionListItem) item).getValue()))) {
    92                 // only in the latter case do we have to
    9387            // lookup and select a matching item
    94                 item = lookupItem(curText);
     88            Object item = lookupItem(curText);
    9589            setSelectedItem(item);
    96             }
    9790            if (initial) {
    9891                start = 0;
     
    121114        }
    122115
    123         private AutoCompletionListItem lookupItem(String pattern) {
     116        private Object lookupItem(String pattern) {
    124117            ComboBoxModel model = comboBox.getModel();
    125118            AutoCompletionListItem bestItem = null;
    126119            for (int i = 0, n = model.getSize(); i < n; i++) {
    127120                AutoCompletionListItem currentItem = (AutoCompletionListItem) model.getElementAt(i);
     121                if (currentItem.getValue().equals(pattern)) {
     122                    return currentItem;
     123                }
    128124                if (currentItem.getValue().startsWith(pattern)) {
    129125                    if (bestItem == null || currentItem.getPriority().compareTo(bestItem.getPriority()) > 0) {
Note: See TracChangeset for help on using the changeset viewer.