Revision: 13150
http://sourceforge.net/p/foray/code/13150
Author: victormote
Date: 2023-08-08 17:26:16 +0000 (Tue, 08 Aug 2023)
Log Message:
-----------
Fix miscount of attribute length.
Modified Paths:
--------------
trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayPrettyOutput.java
Modified: trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayPrettyOutput.java
===================================================================
--- trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayPrettyOutput.java 2023-08-08 16:34:35 UTC (rev 13149)
+++ trunk/foray/foray-xml/src/main/java/org/foray/xml/ForayPrettyOutput.java 2023-08-08 17:26:16 UTC (rev 13150)
@@ -112,6 +112,17 @@
this.charIndex = charIndex;
}
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("[");
+ builder.append(this.itemIndex);
+ builder.append(", ");
+ builder.append(this.charIndex);
+ builder.append("]");
+ return builder.toString();
+ }
+
}
/** Initial size of {@link #breaksChosen}. */
@@ -370,25 +381,36 @@
endItem = opportunity.itemIndex;
endItemIndex = opportunity.charIndex;
}
+
int size = 0;
for (int i = startItem; i <= endItem; i++) {
- int startIndex = 0;
- int endIndex = 0;
- if (i == startItem) {
- startIndex = startItemIndex;
- }
- if (i == endItem) {
- endIndex = endItemIndex - 1;
+ final CharSequence item = this.toWriteQueue.get(i);
+ if (item instanceof ContingentIndentation) {
+ final ContingentIndentation contingent = (ContingentIndentation) item;
+ if (i == startItem
+ && this.lastColumnWritten < 1) {
+ size += contingent.length();
+ } else {
+ size ++;
+ }
} else {
- final CharSequence item = this.toWriteQueue.get(i);
- endIndex = item.length() - 1;
+ int startIndex = 0;
+ int endIndex = 0;
+ if (i == startItem) {
+ startIndex = startItemIndex;
+ }
+ if (i == endItem) {
+ endIndex = endItemIndex - 1;
+ } else {
+ endIndex = item.length() - 1;
+ }
+ size += endIndex - startIndex;
+ if (i != startItem) {
+ /* For all but the first item, we must add the space that
+ * separates the chunks in order to get the complete size.*/
+ size ++;
+ }
}
- size += endIndex - startIndex;
- if (i != startItem) {
- /* For all but the first item, we must add the space that
- * separates the chunks in order to get the complete size.*/
- size ++;
- }
}
return size;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|