davsclaus commented on code in PR #24284:
URL: https://github.com/apache/camel/pull/24284#discussion_r3488478919
##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java:
##########
@@ -1733,9 +1810,34 @@ private void renderFooter(Frame frame, Rect area) {
}
}
+ int hintsWidth = spans.stream().mapToInt(Span::width).sum();
+ int rightWidth = rightSpans.stream().mapToInt(Span::width).sum();
+ int minGap = rightSpans.isEmpty() ? 0 : 1;
+
+ if (hintsWidth + rightWidth + minGap > area.width()) {
+ // Drop decorative right-side content first
+ rightSpans.clear();
+ rightWidth = 0;
+ minGap = 0;
+ // Drop secondary F-key hints (F2/F3/F6) before tab-specific
action hints.
+ // They are inserted at position 2 (after the first tab hint), so
the last
+ // secondary F-key pair sits at index (2 + secondaryFKey - 2).
+ while (secondaryFKey > 0 && hintsWidth > area.width()) {
+ int dropIdx = 2 + secondaryFKey - 2;
Review Comment:
Bug: when F1 is present (the common case — most tabs have help text), this
formula points to F3 instead of F6, and the loop ends up removing F1 while
keeping F6.
`insertFKeyHints` inserts [F1_k, F1_l, F2_k, F2_l, F3_k, F3_l, F6_k, F6_l]
at position 2. The secondary spans (F2/F3/F6) start at index **4**, not 2. But
`2 + secondaryFKey - 2` = `secondaryFKey` = 6, which points to F3 (index 6),
not F6 (index 8). After three iterations, F1 at [2,3] gets removed while F6
survives — the opposite of the stated intent.
**Suggested fix:** have `insertFKeyHints` return `fKeySpans.size()` (total
count including F1) instead of `fKeySpans.size() - (hasHelp ? 2 : 0)`. Then use
`dropIdx = fKeyTotal` here, with loop condition `fKeyTotal > 2`. This naturally
drops from the end (F6 first) and stops before F1:
```java
while (fKeyTotal > 2 && hintsWidth > area.width()) {
int dropIdx = fKeyTotal;
Span labelSpan = spans.remove(dropIdx + 1);
Span keySpan = spans.remove(dropIdx);
hintsWidth -= keySpan.width() + labelSpan.width();
fKeyTotal -= 2;
}
```
Same change needed in `renderOverviewFooter`.
--
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]