Skip to content

Commit

Permalink
Update Search.java
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Dec 10, 2024
1 parent d43a8d3 commit 24837ea
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions core/src/main/java/hudson/search/Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,19 @@ public void doSuggestOpenSearch(StaplerRequest2 req, StaplerResponse2 rsp, @Quer
public void doSuggest(StaplerRequest2 req, StaplerResponse2 rsp, @QueryParameter String query) throws IOException, ServletException {
Result r = new Result();
for (SuggestedItem item : getSuggestions(req, query)) {
String symbolName = item.item.getSearchIcon();

if (symbolName == null || !symbolName.startsWith("symbol-")) {
symbolName = "symbol-search";
String icon = item.item.getSearchIcon();
String iconXml = null;

if (icon == null) {
iconXml = Symbol.get(new SymbolRequest.Builder().withRaw("symbol-search").build());
} else if (icon.startsWith("symbol-")) {
icon = null;
iconXml = Symbol.get(new SymbolRequest.Builder().withRaw(icon).build());
} else {
icon = item.item.getSearchIcon();
}

r.suggestions.add(new Item(item.getPath(), item.getUrl(), "",
Symbol.get(new SymbolRequest.Builder().withRaw(symbolName).build())));
r.suggestions.add(new Item(item.getPath(), item.getUrl(), icon, iconXml));
}
rsp.serveExposedBean(req, r, Flavor.JSON);
}
Expand Down

0 comments on commit 24837ea

Please sign in to comment.