@@ -69,21 +69,26 @@ class ReplDriver(settings: Array[String],
69
69
*/
70
70
override def sourcesRequired : Boolean = false
71
71
72
- /** Create a fresh and initialized context with IDE mode enabled */
73
- private def initialCtx = {
74
- val rootCtx = initCtx.fresh.addMode(Mode .ReadPositions | Mode .Interactive )
75
- rootCtx.setSetting(rootCtx.settings.YcookComments , true )
76
- rootCtx.setSetting(rootCtx.settings.YreadComments , true )
72
+ private def setupRootCtx (settings : Array [String ], rootCtx : Context ) = {
77
73
setup(settings, rootCtx) match
78
74
case Some ((files, ictx)) =>
79
75
shouldStart = true
76
+ if files.nonEmpty then inContext(ictx)(out.println(i " Ignoring spurious arguments: $files%, % " ))
80
77
ictx.base.initialize()(using ictx)
81
78
ictx
82
79
case None =>
83
80
shouldStart = false
84
81
rootCtx
85
82
}
86
83
84
+ /** Create a fresh and initialized context with IDE mode enabled */
85
+ private def initialCtx = {
86
+ val rootCtx = initCtx.fresh.addMode(Mode .ReadPositions | Mode .Interactive )
87
+ rootCtx.setSetting(rootCtx.settings.YcookComments , true )
88
+ rootCtx.setSetting(rootCtx.settings.YreadComments , true )
89
+ setupRootCtx(rootCtx, settings)
90
+ }
91
+
87
92
/** the initial, empty state of the REPL session */
88
93
final def initialState : State = State (0 , 0 , Map .empty, rootCtx)
89
94
@@ -423,14 +428,7 @@ class ReplDriver(settings: Array[String],
423
428
out.println(s " ${s.name} = ${if s.value == " " then " \"\" " else s.value}" )
424
429
state
425
430
case _ =>
426
- setup(tokenize(arg).toArray, rootCtx) match
427
- case Some ((files, ictx)) =>
428
- inContext(ictx) {
429
- if files.nonEmpty then out.println(i " Ignoring spurious arguments: $files%, % " )
430
- ictx.base.initialize()(using ictx)
431
- rootCtx = ictx
432
- }
433
- case _ =>
431
+ rootCtx = setupRootCtx(tokenize(arg).toArray, rootCtx)
434
432
state.copy(context = rootCtx)
435
433
436
434
case Quit =>
0 commit comments