From e39692924bcc5a0979b8339bf3223b5f0ab05312 Mon Sep 17 00:00:00 2001 From: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> Date: Mon, 16 Sep 2024 08:50:05 -0700 Subject: [PATCH] Fallback to include up to first 9 lines if no match is found Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> --- .../geysermc/discordbot/commands/search/SearchCommand.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/geysermc/discordbot/commands/search/SearchCommand.java b/src/main/java/org/geysermc/discordbot/commands/search/SearchCommand.java index ea93a370..b5964959 100644 --- a/src/main/java/org/geysermc/discordbot/commands/search/SearchCommand.java +++ b/src/main/java/org/geysermc/discordbot/commands/search/SearchCommand.java @@ -264,6 +264,12 @@ private String getDescriptionFieldBody(DocSearchResult result, String query, int } } + if (includedLines.isEmpty()) { + for (int i = 0; i < Math.min(lines.size(), 9); i++) { + includedLines.add(i); + } + } + int lastLine = -1; for (int i : includedLines) { if (lastLine != -1 && i - lastLine > 1) {