Merge pull request #4419 from eatkins/reload-loop

Fix windows reload loop
This commit is contained in:
eugene yokota 2018-10-11 09:19:54 -04:00 committed by GitHub
commit 58648d680e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 9 deletions

View File

@ -23,7 +23,7 @@ import sbt.internal.io.{ EventMonitor, Source, WatchState }
import sbt.internal.util.Types.const
import sbt.internal.util.complete.DefaultParsers
import sbt.internal.util.{ AttributeKey, JLine }
import sbt.io.FileEventMonitor.Event
import sbt.io.FileEventMonitor.{ Creation, Deletion, Event, Update }
import sbt.io._
import sbt.util.{ Level, Logger }
import xsbti.compile.analysis.Stamp
@ -144,6 +144,18 @@ object Watched {
}
scanInput()
}
private[sbt] def onEvent(
sources: Seq[WatchSource],
projectSources: Seq[WatchSource]
): Event[StampedFile] => Watched.Action =
event =>
if (sources.exists(_.accept(event.entry.typedPath.getPath))) Watched.Trigger
else if (projectSources.exists(_.accept(event.entry.typedPath.getPath))) event match {
case Update(prev, cur, _) if prev.value.map(_.stamp) != cur.value.map(_.stamp) => Reload
case _: Creation[_] | _: Deletion[_] => Reload
case _ => Ignore
} else Ignore
private[this] val reRun = if (isWin) "" else " or 'r' to re-run the command"
private def waitMessage(project: String): String =
s"Waiting for source changes$project... (press enter to interrupt$reRun)"

View File

@ -621,14 +621,8 @@ object Defaults extends BuildCommon {
consoleProject := consoleProjectTask.value,
watchTransitiveSources := watchTransitiveSourcesTask.value,
watchProjectTransitiveSources := watchTransitiveSourcesTaskImpl(watchProjectSources).value,
watchOnEvent := {
val sources = watchTransitiveSources.value
val projectSources = watchProjectTransitiveSources.value
e =>
if (sources.exists(_.accept(e.entry.typedPath.getPath))) Watched.Trigger
else if (projectSources.exists(_.accept(e.entry.typedPath.getPath))) Watched.Reload
else Watched.Ignore
},
watchOnEvent := Watched
.onEvent(watchTransitiveSources.value, watchProjectTransitiveSources.value),
watchHandleInput := Watched.handleInput,
watchPreWatch := { (_, _) =>
Watched.Ignore