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