diff options
author | Lillian Angel <langel@redhat.com> | 2006-01-12 21:44:59 +0000 |
---|---|---|
committer | Lillian Angel <langel@redhat.com> | 2006-01-12 21:44:59 +0000 |
commit | afb23d75c61a0c514da36c097f5d3d07cbd68ca7 (patch) | |
tree | 00873921a021690a54a00159e931b16b101558ff /javax | |
parent | efe0befcda43f9ceec77f1c773134c78ec249744 (diff) | |
download | classpath-afb23d75c61a0c514da36c097f5d3d07cbd68ca7.tar.gz |
2006-12-12 Lillian Angel <langel@redhat.com>
* javax/swing/text/DefaultStyledDocument.java
(insertUpdate): Added check to check if attribute set is
empty.
(insertUpdate): Added check to determine if last character
is a newline. If it is, we should not be fracturing.
(insert): Added check to determine if attribute set is empty.
If it is, insertUpdate should not be called.
Diffstat (limited to 'javax')
-rw-r--r-- | javax/swing/text/DefaultStyledDocument.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/javax/swing/text/DefaultStyledDocument.java b/javax/swing/text/DefaultStyledDocument.java index 396f32052..06fd631de 100644 --- a/javax/swing/text/DefaultStyledDocument.java +++ b/javax/swing/text/DefaultStyledDocument.java @@ -1671,7 +1671,7 @@ public class DefaultStyledDocument extends AbstractDocument { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. - if (attr == null) + if (attr == null || attr.getAttributeCount() == 0) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); @@ -1759,11 +1759,25 @@ public class DefaultStyledDocument extends AbstractDocument // If we are inserting after a newline then this value comes from // handleInsertAfterNewline. if (finalStartTag != null) - { + { if (prevCharWasNewline) finalStartTag.setDirection(finalStartDirection); else if (prevParagraph.getEndOffset() != endOffset) - finalStartTag.setDirection(ElementSpec.JoinFractureDirection); + { + try + { + String last = getText(endOffset - 1, 1); + if (!last.equals("\n")) + finalStartTag.setDirection(ElementSpec.JoinFractureDirection); + } + catch (BadLocationException ble) + { + // This shouldn't happen. + AssertionError ae = new AssertionError(); + ae.initCause(ble); + throw ae; + } + } else { // If there is an element AFTER this one, then set the @@ -1958,7 +1972,7 @@ public class DefaultStyledDocument extends AbstractDocument { ElementSpec spec = data[i]; AttributeSet atts = spec.getAttributes(); - if (atts != null) + if (atts != null && atts.getAttributeCount() != 0) insertUpdate(ev, atts); } |