diff --git a/engine/runtime/src/main/scala/org/enso/interpreter/instrument/command/EditFileCmd.scala b/engine/runtime/src/main/scala/org/enso/interpreter/instrument/command/EditFileCmd.scala index b2809d9b8f..7591ae254f 100644 --- a/engine/runtime/src/main/scala/org/enso/interpreter/instrument/command/EditFileCmd.scala +++ b/engine/runtime/src/main/scala/org/enso/interpreter/instrument/command/EditFileCmd.scala @@ -27,10 +27,13 @@ class EditFileCmd(request: Api.EditFileNotification) extends Command(None) { val edits = request.edits.map(edit => PendingEdit.ApplyEdit(edit, request.execute)) ctx.state.pendingEdits.enqueue(request.path, edits) - ctx.jobControlPlane.abortAllJobs() - ctx.jobProcessor.run(new EnsureCompiledJob(Seq(request.path))) if (request.execute) { + ctx.jobControlPlane.abortAllJobs() + ctx.jobProcessor.run(new EnsureCompiledJob(Seq(request.path))) executeJobs.foreach(ctx.jobProcessor.run) + } else { + ctx.jobControlPlane.abortAllExcept(classOf[ExecuteJob]) + ctx.jobProcessor.run(new EnsureCompiledJob(Seq(request.path))) } Future.successful(()) } finally { diff --git a/engine/runtime/src/main/scala/org/enso/interpreter/instrument/execution/JobControlPlane.scala b/engine/runtime/src/main/scala/org/enso/interpreter/instrument/execution/JobControlPlane.scala index 5464cc8384..c3b17d0482 100644 --- a/engine/runtime/src/main/scala/org/enso/interpreter/instrument/execution/JobControlPlane.scala +++ b/engine/runtime/src/main/scala/org/enso/interpreter/instrument/execution/JobControlPlane.scala @@ -1,15 +1,22 @@ package org.enso.interpreter.instrument.execution +import org.enso.interpreter.instrument.job.Job + import java.util.UUID /** Controls running jobs. */ trait JobControlPlane { - /** Aborts all interruptible jobs. - */ + /** Aborts all interruptible jobs. */ def abortAllJobs(): Unit + /** Abort all jobs except the ignored jobs. + * + * @param ignoredJobs the list of jobs to keep in the execution queue + */ + def abortAllExcept(ignoredJobs: Class[_ <: Job[_]]*): Unit + /** Aborts all jobs that relates to the specified execution context. * * @param contextId an identifier of a context diff --git a/engine/runtime/src/main/scala/org/enso/interpreter/instrument/execution/JobExecutionEngine.scala b/engine/runtime/src/main/scala/org/enso/interpreter/instrument/execution/JobExecutionEngine.scala index 9af78f739b..e36953b1ec 100644 --- a/engine/runtime/src/main/scala/org/enso/interpreter/instrument/execution/JobExecutionEngine.scala +++ b/engine/runtime/src/main/scala/org/enso/interpreter/instrument/execution/JobExecutionEngine.scala @@ -128,9 +128,17 @@ final class JobExecutionEngine( } /** @inheritdoc */ - override def abortAllJobs(): Unit = { - val allJobs = runningJobsRef.updateAndGet(_.filterNot(_.future.isCancelled)) - val cancellableJobs = allJobs.filter(_.job.isCancellable) + override def abortAllJobs(): Unit = + abortAllExcept() + + /** @inheritdoc */ + override def abortAllExcept(ignoredJobs: Class[_ <: Job[_]]*): Unit = { + val allJobs = runningJobsRef.updateAndGet(_.filterNot(_.future.isCancelled)) + val cancellableJobs = allJobs + .filter { runningJob => + runningJob.job.isCancellable && + !ignoredJobs.contains(runningJob.job.getClass) + } cancellableJobs.foreach { runningJob => runningJob.future.cancel(runningJob.job.mayInterruptIfRunning) }