Ticket #21375: 21375.patch

File 21375.patch, 1.5 KB (added by marcello@…, 5 years ago)

Quick and dirty patch: exempt <different> from max length restriction

  • src/org/openstreetmap/josm/gui/tagging/ac/MaxLengthDocumentFilter.java

     
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.tagging.ac;
    33
     4import static org.openstreetmap.josm.tools.I18n.tr;
     5
    46import javax.swing.text.AttributeSet;
    57import javax.swing.text.BadLocationException;
    68import javax.swing.text.DocumentFilter;
     
    1315public class MaxLengthDocumentFilter extends DocumentFilter {
    1416    /** the document will not accept text longer than this. -1 to disable */
    1517    private int maxLength = -1;
     18    private static final String DIFFERENT = tr("<different>");
    1619
    1720    /**
    1821     * Sets the maximum text length.
     
    4144
    4245    private boolean mustInsertOrReplace(FilterBypass fb, int length, String string, AttributeSet attr) {
    4346        int newLen = fb.getDocument().getLength() - length + ((string == null) ? 0 : string.length());
    44         return (maxLength == -1 || newLen <= maxLength ||
     47        return (maxLength == -1 || newLen <= maxLength || DIFFERENT.equals(string) ||
    4548                // allow longer text while composing characters or it will be hard to compose
    4649                // the last characters before the limit
    4750                ((attr != null) && attr.isDefined(StyleConstants.ComposedTextAttribute)));