Revision: 6442
          http://sourceforge.net/p/jump-pilot/code/6442
Author:   michaudm
Date:     2020-09-12 09:05:16 +0000 (Sat, 12 Sep 2020)
Log Message:
-----------
Improve splitting text for long error messages

Modified Paths:
--------------
    core/trunk/src/com/vividsolutions/jump/util/StringUtil.java

Modified: core/trunk/src/com/vividsolutions/jump/util/StringUtil.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/util/StringUtil.java 2020-09-11 
19:17:31 UTC (rev 6441)
+++ core/trunk/src/com/vividsolutions/jump/util/StringUtil.java 2020-09-12 
09:05:16 UTC (rev 6442)
@@ -94,18 +94,15 @@
      */
     public static String split(String s, int n) {
         StringBuilder b = new StringBuilder();
-        boolean wrapPending = false;
-
+        int index = 0;
         for (int i = 0; i < s.length(); i++) {
-            if (((i % n) == 0) && (i > 0)) {
-                wrapPending = true;
-            }
 
             char c = s.charAt(i);
+            index++;
 
-            if (wrapPending && (c == ' ')) {
+            if (c == '\n' || (index >= n && (c == ' '))) {
                 b.append("\n");
-                wrapPending = false;
+                index = 0;
             } else {
                 b.append(c);
             }



_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to