Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve auto-reload #4926

Merged
merged 1 commit into from Aug 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 17 additions & 18 deletions main/src/main/scala/sbt/MainLoop.scala
Expand Up @@ -200,26 +200,25 @@ object MainLoop {
}
newState
}
val checkCommand = state.currentCommand match {
// If the user runs reload directly, we want to be sure that we update the previous
// cache for checkBuildSources / changedInputFiles but we don't want to display any
// warnings. Without filling the previous cache, it's possible for the user to run
// reload and be prompted with a warning in spite of reload having just run and no build
// sources having changed.
case Some(exec) if exec.commandLine == "reload" => "checkBuildSources / changedInputFiles"
case _ => "checkBuildSources"
}
Parser.parse(
checkCommand,
state.copy(remainingCommands = Nil).put(Aggregation.suppressShow, true).combinedParser
) match {
case Right(cmd) =>
cmd() match {
case s if s.remainingCommands.headOption.map(_.commandLine).contains("reload") =>
Exec("reload", None, None) +: exec +: state
// The split on space is to handle 'reboot full' and 'reboot'.
state.currentCommand.flatMap(_.commandLine.trim.split(" ").headOption) match {
case Some("reload") =>
// Reset the hasCheckedMetaBuild parameter so that the next call to checkBuildSources
// updates the previous cache for checkBuildSources / fileInputStamps but doesn't log.
state.get(hasCheckedMetaBuild).foreach(_.set(false))
process()
case Some("exit") | Some("reboot") => process()
case _ =>
val emptyState = state.copy(remainingCommands = Nil).put(Aggregation.suppressShow, true)
Parser.parse("checkBuildSources", emptyState.combinedParser) match {
case Right(cmd) =>
cmd() match {
case s if s.remainingCommands.headOption.map(_.commandLine).contains("reload") =>
Exec("reload", None, None) +: exec +: state
case _ => process()
}
case _ => process()
}
case Left(_) => process()
}
} catch {
case err: Throwable =>
Expand Down