Skip to content

Commit

Permalink
fix prefix-based matching of variants prompt
Browse files Browse the repository at this point in the history
fixes #12
  • Loading branch information
memo33 committed Nov 18, 2024
1 parent 46fe321 commit 259d4ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
### Fixed
- an issue affecting some old terminals in which the escape sequences used for displaying progress bars were incorrectly printed to the console (#8)
- an issue that could cause warning messages to mess up the prompt display (#5)
- an issue that prevented selecting some variants if a prompt had 10+ variants (#12)

### Changed
- improved error message if channel-build fails randomly in case old files could not be removed (#6)
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/sc4pac/Prompt.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ object Prompt {
} yield {
if (input.isEmpty) default
else {
val matches: Seq[String] = options.filter(_.toLowerCase(java.util.Locale.ENGLISH).startsWith(input.toLowerCase(java.util.Locale.ENGLISH)))
matches match {
val inputLower = input.toLowerCase(java.util.Locale.ENGLISH)
options.filter(_.toLowerCase(java.util.Locale.ENGLISH).startsWith(inputLower)) match {
case Seq(unique) => Some(unique)
case _ => None
case matches => matches.find(_ == input).orElse(matches.find(_.toLowerCase(java.util.Locale.ENGLISH) == inputLower))
}
}
}
Expand Down

0 comments on commit 259d4ef

Please sign in to comment.