From 24837ea667183f189ee0ab73e86cb8cda58c8fe2 Mon Sep 17 00:00:00 2001 From: Jan Faracik <43062514+janfaracik@users.noreply.github.com> Date: Tue, 10 Dec 2024 21:59:03 +0000 Subject: [PATCH] Update Search.java --- core/src/main/java/hudson/search/Search.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/hudson/search/Search.java b/core/src/main/java/hudson/search/Search.java index a3c76a7fc9..853c8ea851 100644 --- a/core/src/main/java/hudson/search/Search.java +++ b/core/src/main/java/hudson/search/Search.java @@ -160,14 +160,19 @@ public class Search implements StaplerProxy { 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(); + String icon = item.item.getSearchIcon(); + String iconXml = null; - if (symbolName == null || !symbolName.startsWith("symbol-")) { - symbolName = "symbol-search"; + 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); }