Skip to content

Commit

Permalink
Fix auto complete dropping the wrong amount of suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: shedaniel <[email protected]>
  • Loading branch information
shedaniel committed Jan 20, 2022
1 parent 63f3866 commit 9a93218
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class SlashCommands(
get() = options != null

override fun suggest(it: Iterable<ApplicationCommandOptionChoiceData>) {
options = it.toList()
options = it.toList().take(25)
}
}
runCatching {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ open class QueryMappingsCommand(
val provider = options.optNullable(version, VersionNamespaceConfig(namespace)) ?: namespace.getDefaultProvider()
val mappings = provider.get()
val result = query(mappings, value, *types)
val suggestions = result.results.asSequence().take(25).map { (value, _) ->
val suggestions = result.results.asSequence().take(24).map { (value, _) ->
when {
value is Class -> {
// if (value.mappedName != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class QueryTranslateMappingsCommand(
val provider = options.optNullable(version, VersionNamespaceConfig(src, defaultVersion) { allVersions }) ?: src.getProvider(defaultVersion)
val mappings = provider.get()
val result = MappingsQueryUtils.query(mappings, value, *types)
val suggestions = result.results.asSequence().take(25).map { (value, _) ->
val suggestions = result.results.asSequence().take(24).map { (value, _) ->
when {
value is Class -> {
sink.choice(value.optimumName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fun StringCommandOption.suggestStrings(versionsGetter: (SuggestionOptionsGetter)
compareByDescending<String> { if (it.startsWith(value)) 1 else 0 }
.thenByDescending { it.similarity(value) }
)
.take(25)
.take(24)
.map { sink.choice(it, it) }
.toList()
sink.suggest(listOf(sink.choice(value)) + suggestions)
Expand Down

0 comments on commit 9a93218

Please sign in to comment.