|
37 | 37 | import java.util.ArrayList; |
38 | 38 | import java.util.Collections; |
39 | 39 | import java.util.List; |
40 | | -import java.util.Locale; |
41 | 40 | import java.util.concurrent.CompletableFuture; |
42 | 41 | import java.util.function.Supplier; |
43 | 42 | import org.apiguardian.api.API; |
@@ -173,27 +172,36 @@ public final ArgumentType<T> getNativeArgument() { |
173 | 172 | */ |
174 | 173 | final com.mojang.brigadier.context.CommandContext<Object> reverseMappedContext = new com.mojang.brigadier.context.CommandContext<>( |
175 | 174 | commandContext.getOrDefault(COMMAND_CONTEXT_BRIGADIER_NATIVE_SENDER, commandContext.sender()), |
176 | | - commandContext.rawInput().input(), |
| 175 | + input.input(), |
177 | 176 | Collections.emptyMap(), |
178 | 177 | null, |
179 | 178 | null, |
180 | 179 | Collections.emptyList(), |
181 | | - StringRange.at(0), |
| 180 | + StringRange.at(input.cursor()), |
182 | 181 | null, |
183 | 182 | null, |
184 | 183 | false |
185 | 184 | ); |
186 | 185 |
|
187 | 186 | return this.nativeType.get().listSuggestions( |
188 | 187 | reverseMappedContext, |
189 | | - new SuggestionsBuilder(input.input(), input.input().toLowerCase(Locale.ROOT), input.cursor()) |
| 188 | + new SuggestionsBuilder(input.input(), input.cursor()) |
190 | 189 | ).thenApply(suggestions -> { |
191 | 190 | final List<cloud.commandframework.arguments.suggestion.Suggestion> cloud = new ArrayList<>(); |
192 | 191 | for (final com.mojang.brigadier.suggestion.Suggestion suggestion : suggestions.getList()) { |
193 | | - cloud.add(tooltipSuggestion( |
194 | | - suggestion.getText(), |
195 | | - suggestion.getTooltip() |
196 | | - )); |
| 192 | + final String beforeSuggestion = input.input().substring(input.cursor(), suggestion.getRange().getStart()); |
| 193 | + final String afterSuggestion = input.input().substring(suggestion.getRange().getEnd()); |
| 194 | + if (beforeSuggestion.isEmpty() && afterSuggestion.isEmpty()) { |
| 195 | + cloud.add(tooltipSuggestion( |
| 196 | + suggestion.getText(), |
| 197 | + suggestion.getTooltip() |
| 198 | + )); |
| 199 | + } else { |
| 200 | + cloud.add(tooltipSuggestion( |
| 201 | + beforeSuggestion + suggestion.getText() + afterSuggestion, |
| 202 | + suggestion.getTooltip() |
| 203 | + )); |
| 204 | + } |
197 | 205 | } |
198 | 206 | return cloud; |
199 | 207 | }); |
|
0 commit comments