From 7c7576843a3517cfeb36786767b57dec7d4ebeed Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 1 Jun 2023 22:45:51 -0400 Subject: [PATCH] Fix sbt init menu Problem ------- sbt init menu doesn't pick the right template in the latter half. Solution -------- This fixes the mapping between the position and the letter. --- main/src/main/scala/sbt/TemplateCommandUtil.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main/src/main/scala/sbt/TemplateCommandUtil.scala b/main/src/main/scala/sbt/TemplateCommandUtil.scala index e750a65cb..c8a611aa2 100644 --- a/main/src/main/scala/sbt/TemplateCommandUtil.scala +++ b/main/src/main/scala/sbt/TemplateCommandUtil.scala @@ -183,7 +183,7 @@ private[sbt] object TemplateCommandUtil { else ITerminal.withStreams(true, false) { val mappingList = templates.zipWithIndex.map { - case (v, idx) => nonMoveLetters(idx).toString -> v + case (v, idx) => toLetter(idx) -> v } val out = term.printStream out.println("") @@ -194,10 +194,13 @@ private[sbt] object TemplateCommandUtil { mappings.get(ans).map(_._1).toList } + private def toLetter(idx: Int): String = + nonMoveLetters(idx).toString + private def askTemplate(mappingList: List[(String, (String, String))], focus: Int): String = { val msg = "Select a template" displayMappings(mappingList, focus) - val focusValue = ('a' + focus).toChar.toString + val focusValue = toLetter(focus) if (!isAnsiSupported) ask(msg, focusValue) else { val out = term.printStream