Ticket #5927: josm_5876_2.patch
File josm_5876_2.patch, 1.8 KB (added by , 13 years ago) |
---|
-
tagging/ac/AutoCompletingComboBox.java
84 84 } 85 85 } 86 86 87 // the string being inserted might be a "full" string from the list88 // of valid completions (instanceof AutoCompletionListItem), or a89 // "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 to93 87 // lookup and select a matching item 94 88 Object item = lookupItem(curText); 95 89 setSelectedItem(item); 96 }97 90 if (initial) { 98 91 start = 0; 99 92 } … … 120 113 selecting = false; 121 114 } 122 115 123 private AutoCompletionListItemlookupItem(String pattern) {116 private Object lookupItem(String pattern) { 124 117 ComboBoxModel model = comboBox.getModel(); 125 118 AutoCompletionListItem bestItem = null; 126 119 for (int i = 0, n = model.getSize(); i < n; i++) { 127 120 AutoCompletionListItem currentItem = (AutoCompletionListItem) model.getElementAt(i); 121 if (currentItem.getValue().equals(pattern)) { 122 return currentItem; 123 } 128 124 if (currentItem.getValue().startsWith(pattern)) { 129 125 if (bestItem == null || currentItem.getPriority().compareTo(bestItem.getPriority()) > 0) { 130 126 bestItem = currentItem;