This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch fix/CAMEL-25411-count in repository https://gitbox.apache.org/repos/asf/camel.git
commit 801a0a62ddde19bdbe219f54ef306ade26af60c2 Author: Claus Ibsen <[email protected]> AuthorDate: Wed Oct 7 14:15:29 2026 +0200 CAMEL-25411: camel-jbang - Source editor: the options popup of a kamelet: endpoint counts the Kamelet's properties The title counted all the items, the options of the kamelet component below the divider included (tag-order-action options (9)). It now counts the properties of the Kamelet (2), or shown/total of them while filtering. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m --- .../jbang/core/commands/tui/AutocompletePopup.java | 23 ++++++++++++++++------ .../commands/tui/SourceKameletValidationTest.java | 8 ++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/AutocompletePopup.java b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/AutocompletePopup.java index 4552ee285820..e95fc700a6f8 100644 --- a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/AutocompletePopup.java +++ b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/AutocompletePopup.java @@ -382,12 +382,7 @@ class AutocompletePopup { renderState.select(sel + 2 + (dividerAt >= 0 && sel >= dividerAt ? 1 : 0)); } - int total = allItems.size(); - int shown = filteredItems.size(); - String label = titlePrefix != null ? titlePrefix : "Completions"; - String title = shown == total - ? " " + label + " (" + total + ") " - : " " + label + " (" + shown + "/" + total + ") "; + String title = title(); ListWidget list = ListWidget.builder() .items(items.toArray(ListItem[]::new)) @@ -597,6 +592,22 @@ class AutocompletePopup { listState.select(filteredItems.isEmpty() ? null : 0); } + /** + * The title of the list with its count. When the list has the properties of a Kamelet, the count is of those: the + * options of the kamelet component below the divider are for special uses, and not what the title names + * (CAMEL-25411). + */ + String title() { + String label = titlePrefix != null ? titlePrefix : "Completions"; + boolean kamelet = allItems.stream().anyMatch(AutocompletePopup::isKameletProperty); + long total = kamelet ? allItems.stream().filter(AutocompletePopup::isKameletProperty).count() : allItems.size(); + long shown = kamelet + ? filteredItems.stream().filter(AutocompletePopup::isKameletProperty).count() : filteredItems.size(); + return shown == total + ? " " + label + " (" + total + ") " + : " " + label + " (" + shown + "/" + total + ") "; + } + private static boolean isKameletProperty(CompletionItem item) { return item.group() != null && item.group().startsWith(KAMELET_GROUP); } diff --git a/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceKameletValidationTest.java b/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceKameletValidationTest.java index a8e046633e76..d1f584cf620d 100644 --- a/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceKameletValidationTest.java +++ b/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceKameletValidationTest.java @@ -160,6 +160,14 @@ class SourceKameletValidationTest { // filtering keeps the property of the Kamelet above: "t" matches tag and timeout AutocompletePopup filtered = new AutocompletePopup(items, "t", "t"); assertThat(filtered.dividerAt()).isEqualTo(1); + // the title counts the properties of the Kamelet, not the options of the kamelet component + AutocompletePopup all = new AutocompletePopup(items, "", ""); + all.setTitlePrefix("tag-order-action options"); + assertThat(all.title()).isEqualTo(" tag-order-action options (1) "); + // "rout" matches routeId only: none of the Kamelet's properties shown + AutocompletePopup component = new AutocompletePopup(items, "rout", "rout"); + component.setTitlePrefix("tag-order-action options"); + assertThat(component.title()).isEqualTo(" tag-order-action options (0/1) "); // only the Kamelet's properties left, or none: no divider assertThat(new AutocompletePopup(items, "tag", "tag").dividerAt()).isEqualTo(-1); assertThat(new AutocompletePopup(items, "routeId", "routeId").dividerAt()).isEqualTo(-1);
