Keep project selection upon reload.

This commit is contained in:
Eugene Vigdorchik 2012-01-31 19:12:52 +04:00
parent 1f0a45e950
commit 8daa6d3279
4 changed files with 26 additions and 5 deletions

View File

@ -533,13 +533,18 @@ object Load
}
}
def initialSession(structure: BuildStructure, rootEval: () => Eval, s: State): SessionSettings = {
val current = s get Keys.sessionSettings map (_.currentProject)
new SessionSettings(structure.root, projectMap(structure.units, current), structure.settings, Map.empty, Nil, rootEval)
}
def initialSession(structure: BuildStructure, rootEval: () => Eval): SessionSettings =
new SessionSettings(structure.root, rootProjectMap(structure.units), structure.settings, Map.empty, Nil, rootEval)
new SessionSettings(structure.root, projectMap(structure.units, None), structure.settings, Map.empty, Nil, rootEval)
def rootProjectMap(units: Map[URI, LoadedBuildUnit]): Map[URI, String] =
def projectMap(units: Map[URI, LoadedBuildUnit], current: Option[Map[URI, String]]): Map[URI, String] =
{
val getRoot = getRootProject(units)
units.keys.map(uri => (uri, getRoot(uri))).toMap
units.keys.map(uri => (uri, current.flatMap(_ get uri) getOrElse getRoot(uri))).toMap
}
def defaultEvalOptions: Seq[String] = Nil

View File

@ -335,8 +335,8 @@ object BuiltinCommands
val (s, base) = Project.loadAction(SessionVar.clear(s0), action)
IO.createDirectory(base)
val (eval, structure) = Load.defaultLoad(s, base, logger(s))
val session = Load.initialSession(structure, eval)
val session = Load.initialSession(structure, eval, s0)
SessionSettings.checkSession(session, s)
Project.setProject(session, structure, s)
}
}
}

View File

@ -0,0 +1,11 @@
import sbt._
object TestBuild extends Build
{
lazy val root = Project("root", file("."), aggregate = Seq(sub)) settings(
TaskKey[Unit]("f") := error("f")
)
lazy val sub = Project("sub", file("sub")) settings(
TaskKey[Unit]("f") := {}
)
}

View File

@ -0,0 +1,5 @@
-> f
> project sub
> f
> reload
> f