Ticket #5876: josm_5876.patch

File josm_5876.patch, 1.3 KB (added by ax, 15 years ago)
  • tagging/ac/AutoCompletingComboBox.java

     
    8484                }
    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
    8793            // lookup and select a matching item
    88             Object item = lookupItem(curText);
     94                item = lookupItem(curText);
    8995            setSelectedItem(item);
     96            }
    9097            if (initial) {
    9198                start = 0;
    9299            }
     
    113120            selecting = false;
    114121        }
    115122
    116         private Object lookupItem(String pattern) {
     123        private AutoCompletionListItem lookupItem(String pattern) {
    117124            ComboBoxModel model = comboBox.getModel();
    118125            AutoCompletionListItem bestItem = null;
    119126            for (int i = 0, n = model.getSize(); i < n; i++) {