@@ -205,7 +205,7 @@ class ReplDriver(settings: Array[String],
205
205
label
206
206
207
207
/** Extract possible completions at the index of `cursor` in `expr` */
208
- protected final def completions (cursor : Int , expr : String , state0 : State ): List [Candidate ] = {
208
+ protected final def completions (cursor : Int , expr : String , state0 : State ): List [Candidate ] =
209
209
def makeCandidate (label : String ) = {
210
210
211
211
new Candidate (
@@ -218,20 +218,24 @@ class ReplDriver(settings: Array[String],
218
218
/* complete = */ false // if true adds space when completing
219
219
)
220
220
}
221
- implicit val state = newRun(state0)
222
- compiler
223
- .typeCheck(expr, errorsAllowed = true )
224
- .map { tree =>
225
- val file = SourceFile .virtual(" <completions>" , expr, maybeIncomplete = true )
226
- val unit = CompilationUnit (file)(using state.context)
227
- unit.tpdTree = tree
228
- given Context = state.context.fresh.setCompilationUnit(unit)
229
- val srcPos = SourcePosition (file, Span (cursor))
230
- val (_, completions) = Completion .completions(srcPos)
231
- completions.map(_.label).distinct.map(makeCandidate)
232
- }
233
- .getOrElse(Nil )
234
- }
221
+
222
+ if expr.startsWith(" :" ) then
223
+ ParseResult .commands.map(command => makeCandidate(command._1))
224
+ else
225
+ given state : State = newRun(state0)
226
+ compiler
227
+ .typeCheck(expr, errorsAllowed = true )
228
+ .map { tree =>
229
+ val file = SourceFile .virtual(" <completions>" , expr, maybeIncomplete = true )
230
+ val unit = CompilationUnit (file)(using state.context)
231
+ unit.tpdTree = tree
232
+ given Context = state.context.fresh.setCompilationUnit(unit)
233
+ val srcPos = SourcePosition (file, Span (cursor))
234
+ val (_, completions) = Completion .completions(srcPos)
235
+ completions.map(_.label).distinct.map(makeCandidate)
236
+ }
237
+ .getOrElse(Nil )
238
+ end completions
235
239
236
240
private def interpret (res : ParseResult )(implicit state : State ): State = {
237
241
res match {
0 commit comments