File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed
compiler/src/dotty/tools/repl Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ sealed trait Command extends ParseResult
4242case class UnknownCommand (cmd : String ) extends Command
4343
4444/** An ambiguous prefix that matches multiple commands */
45- case class AmbiguousCommand (cmd : String ) extends Command
45+ case class AmbiguousCommand (cmd : String , matchingCommands : List [ String ] ) extends Command
4646
4747/** `:load <path>` interprets a scala file as if entered line-by-line into
4848 * the REPL
@@ -134,13 +134,11 @@ object ParseResult {
134134 sourceCode match {
135135 case " " => Newline
136136 case CommandExtract (cmd, arg) => {
137- val matchingParsers = commands.collect {
138- case (command, f) if command.startsWith(cmd) => f
139- }
140- matchingParsers match {
137+ val matchingCommands = commands.filter((command, _) => command.startsWith(cmd))
138+ matchingCommands match {
141139 case Nil => UnknownCommand (cmd)
142- case f :: Nil => f(arg)
143- case _ => AmbiguousCommand (cmd)
140+ case (_, f) :: Nil => f(arg)
141+ case multiple => AmbiguousCommand (cmd, multiple.map(_._1) )
144142 }
145143 }
146144 case _ =>
Original file line number Diff line number Diff line change @@ -329,8 +329,8 @@ class ReplDriver(settings: Array[String],
329329 out.println(s """ Unknown command: " $cmd", run ":help" for a list of commands """ )
330330 state
331331
332- case AmbiguousCommand (cmd) =>
333- out.println(s """ " $cmd" matches more than one command . Try typing a few more characters. Run ":help" for a list of commands """ )
332+ case AmbiguousCommand (cmd, matching ) =>
333+ out.println(s """ " $cmd" matches ${matching.mkString( " , " )} . Try typing a few more characters. Run ":help" for a list of commands """ )
334334 state
335335
336336 case Help =>
You can’t perform that action at this time.
0 commit comments