Ticket #21375: 21375.patch
| File 21375.patch, 1.5 KB (added by , 5 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/tagging/ac/MaxLengthDocumentFilter.java
1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.tagging.ac; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 6 import javax.swing.text.AttributeSet; 5 7 import javax.swing.text.BadLocationException; 6 8 import javax.swing.text.DocumentFilter; … … 13 15 public class MaxLengthDocumentFilter extends DocumentFilter { 14 16 /** the document will not accept text longer than this. -1 to disable */ 15 17 private int maxLength = -1; 18 private static final String DIFFERENT = tr("<different>"); 16 19 17 20 /** 18 21 * Sets the maximum text length. … … 41 44 42 45 private boolean mustInsertOrReplace(FilterBypass fb, int length, String string, AttributeSet attr) { 43 46 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) || 45 48 // allow longer text while composing characters or it will be hard to compose 46 49 // the last characters before the limit 47 50 ((attr != null) && attr.isDefined(StyleConstants.ComposedTextAttribute)));
