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
42
42
case class UnknownCommand (cmd : String ) extends Command
43
43
44
44
/** 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
46
46
47
47
/** `:load <path>` interprets a scala file as if entered line-by-line into
48
48
* the REPL
@@ -134,13 +134,11 @@ object ParseResult {
134
134
sourceCode match {
135
135
case " " => Newline
136
136
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 {
141
139
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) )
144
142
}
145
143
}
146
144
case _ =>
Original file line number Diff line number Diff line change @@ -329,8 +329,8 @@ class ReplDriver(settings: Array[String],
329
329
out.println(s """ Unknown command: " $cmd", run ":help" for a list of commands """ )
330
330
state
331
331
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 """ )
334
334
state
335
335
336
336
case Help =>
You can’t perform that action at this time.
0 commit comments