davsclaus commented on code in PR #24064:
URL: https://github.com/apache/camel/pull/24064#discussion_r3435049054
##########
pom.xml:
##########
@@ -426,6 +426,7 @@
<kts>SLASHSTAR_STYLE</kts>
<ldif>LDIF_STYLE</ldif>
<libsonnet>SLASHSTAR_STYLE</libsonnet>
+ <mjs>SLASHSTAR_STYLE</mjs>
Review Comment:
No `.mjs` files are introduced by this PR. Harmless and proactively useful
for future additions, but slightly out of scope.
##########
components/camel-diagram/src/main/java/org/apache/camel/diagram/RouteDiagramHelper.java:
##########
@@ -120,6 +120,50 @@ public static List<RouteInfo> parseRoutes(JsonObject jo) {
return routes;
}
+ static List<String> wrapText(String text, int maxWidth) {
+ if (maxWidth <= 0 || text.length() <= maxWidth) {
+ return List.of(text);
+ }
+
+ List<String> lines = new ArrayList<>();
+ String remaining = text;
+
+ while (!remaining.isEmpty() && lines.size() < MAX_WRAP_LINES) {
+ if (remaining.length() <= maxWidth) {
+ lines.add(remaining);
+ remaining = "";
+ break;
+ }
+
+ int breakAt = -1;
+ for (int i = 0; i < maxWidth && i < remaining.length(); i++) {
+ char c = remaining.charAt(i);
+ if (c == ' ' || c == ':' || c == '/' || c == '.' || c == ','
|| c == '&' || c == '?') {
+ breakAt = i + 1;
+ }
+ }
+ if (breakAt <= 0) {
+ breakAt = maxWidth;
+ }
+
+ lines.add(remaining.substring(0, breakAt).stripTrailing());
+ remaining = remaining.substring(breakAt).stripLeading();
+ }
Review Comment:
The consolidated `wrapText` uses the `RouteDiagramAsciiRenderer` version
(with the `if (lastLine.length() + remaining.length() <= maxWidth)` branch).
The old `TopologyAsciiRenderer` version always truncated with `...` — it didn't
have this "fits on last line" check. This is a subtle but positive behavior
change for topology diagrams: short remainders that previously got `...` will
now be appended cleanly. Non-blocking, just worth noting.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]