mirror of https://github.com/sbt/sbt.git
Merge pull request #8375 from azdrojowa123/reload-on-source-changes
Trigger only load (without loadFailed) in the case of NetworkChannel
This commit is contained in:
commit
df11b264db
|
|
@ -10,6 +10,7 @@ package sbt
|
|||
|
||||
import sbt.BasicCommandStrings.{ StashOnFailure, networkExecPrefix }
|
||||
import sbt.ProjectExtra.extract
|
||||
import sbt.internal.{ ConsoleChannel, FastTrackCommands, ShutdownHooks, SysProp, TaskProgress }
|
||||
import sbt.internal.langserver.ErrorCodes
|
||||
import sbt.internal.nio.CheckBuildSources.CheckBuildSourcesKey
|
||||
import sbt.internal.protocol.JsonRpcResponseError
|
||||
|
|
@ -20,7 +21,6 @@ import sbt.internal.util.{
|
|||
Prompt,
|
||||
Terminal as ITerminal
|
||||
}
|
||||
import sbt.internal.{ FastTrackCommands, ShutdownHooks, SysProp, TaskProgress }
|
||||
import sbt.io.{ IO, Using }
|
||||
import sbt.protocol.*
|
||||
import sbt.util.{ Logger, LoggerContext }
|
||||
|
|
@ -31,6 +31,7 @@ import java.util.concurrent.RejectedExecutionException
|
|||
import scala.annotation.tailrec
|
||||
import scala.concurrent.duration.*
|
||||
import scala.util.control.NonFatal
|
||||
import sbt.internal.server.NetworkChannel
|
||||
|
||||
import java.text.ParseException
|
||||
|
||||
|
|
@ -301,10 +302,20 @@ private[sbt] object MainLoop:
|
|||
.remove(Keys.terminalKey)
|
||||
.remove(Keys.currentCommandProgress)
|
||||
}
|
||||
|
||||
val channel = channelName.flatMap(exchange.channelForName)
|
||||
val (canReload, useLoadp) = channel match
|
||||
case Some(nc: NetworkChannel) => (exec.execId.nonEmpty, true)
|
||||
case Some(_: ConsoleChannel) => (true, false)
|
||||
case _ => (false, false)
|
||||
|
||||
state.get(CheckBuildSourcesKey) match {
|
||||
case Some(cbs) =>
|
||||
if (!cbs.needsReload(state, exec)) process()
|
||||
else Exec("reload", None) +: exec +: state.remove(CheckBuildSourcesKey)
|
||||
case Some(cbs) if canReload && cbs.needsReload(state, exec) =>
|
||||
val loadExec =
|
||||
if (useLoadp) Exec("loadp", exec.execId, exec.source)
|
||||
else Exec("reload", exec.source)
|
||||
|
||||
loadExec +: exec +: state.remove(CheckBuildSourcesKey)
|
||||
case _ => process()
|
||||
}
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ object BuildServerProtocol {
|
|||
jvmTestEnvironmentProvider = true,
|
||||
)
|
||||
|
||||
private val bspReload = "bspReload"
|
||||
val bspReload = "bspReload"
|
||||
|
||||
private val targetIdentifierParser: Parser[Seq[BuildTargetIdentifier]] =
|
||||
Def
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import sbt.ProjectExtra.extract
|
|||
import sbt.Scope.Global
|
||||
import sbt.internal.CommandStrings.LoadProject
|
||||
import sbt.internal.SysProp
|
||||
import sbt.internal.server.BuildServerProtocol
|
||||
import sbt.internal.util.{ AttributeKey, Terminal }
|
||||
import sbt.io.syntax.*
|
||||
import sbt.nio.FileChanges
|
||||
|
|
@ -93,7 +94,7 @@ private[sbt] class CheckBuildSources extends AutoCloseable {
|
|||
val commands =
|
||||
allCmds.flatMap(_.split(";").flatMap(_.trim.split(" ").headOption).filterNot(_.isEmpty))
|
||||
val filter = (c: String) =>
|
||||
c == LoadProject || c == RebootCommand || c == TerminateAction || c == Shutdown ||
|
||||
c == LoadProject || c == BuildServerProtocol.bspReload || c == RebootCommand || c == TerminateAction || c == Shutdown ||
|
||||
c.startsWith("sbtReboot")
|
||||
val resetState = commands.exists(filter)
|
||||
if (resetState) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue