Ignore:
Timestamp:
2015-04-25T20:57:20+02:00 (9 years ago)
Author:
simon04
Message:

fix #9533 - Do not autocomplete in combo boxes unless cursor is at the end

File:
1 edited

Legend:

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

    r7864 r8268  
    6565        @Override
    6666        public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
     67            // TODO get rid of code duplication w.r.t. AutoCompletingTextField.AutoCompletionDocument.insertString
     68
    6769            if (selecting || (offs == 0 && str.equals(getText(0, getLength()))))
    6870                return;
     
    8284            if (a != null && a.isDefined(StyleConstants.ComposedTextAttribute))
    8385                return;
     86
     87            // if the current offset isn't at the end of the document we don't autocomplete.
     88            // If a highlighted autocompleted suffix was present and we get here Swing has
     89            // already removed it from the document. getLength() therefore doesn't include the
     90            // autocompleted suffix.
     91            if (offs + str.length() < getLength()) {
     92                return;
     93            }
    8494
    8595            int size = getLength();
Note: See TracChangeset for help on using the changeset viewer.