Merge pull request #1100 from dansanduleac/sessionSettings2

Fixed SessionSettings replacing existing setting
This commit is contained in:
Josh Suereth 2014-02-02 04:24:49 -08:00
commit 85753e4035
5 changed files with 47 additions and 1 deletions

View File

@ -110,7 +110,7 @@ object SessionSettings
val RangePosition(_, r@LineRange(start, end)) = s.pos
settings find (_._1.key == s.key) match {
case Some(ss@(ns, newLines)) if !ns.init.dependencies.contains(ns.key) =>
val shifted = ns withPos RangePosition(path, LineRange(start - offs, start - offs + 1))
val shifted = ns withPos RangePosition(path, LineRange(start - offs, start - offs + newLines.size))
(offs + end - start - newLines.size, shifted::olds, ss::repl, lineMap + (start -> (end, newLines)))
case _ =>
val shifted = s withPos RangePosition(path, r shift -offs)

View File

@ -0,0 +1,10 @@
name := "projectName"
k1 := {
//
//
}
k2 := {
println("This is k2")
}

View File

@ -0,0 +1,7 @@
name := "projectName"
k1 := {}
k2 := {
println("This is k2")
}

View File

@ -0,0 +1,25 @@
import sbt._
import Keys._
object build extends Build {
lazy val k1 = taskKey[Unit]("")
lazy val k2 = taskKey[Unit]("")
val UpdateK1 = Command.command("UpdateK1") { st: State =>
val ex = Project extract st
import ex._
val session2 = BuiltinCommands.setThis(st, ex, Seq(k1 := {}), """k1 := {
|//
|//
|}""".stripMargin).session
val st1 = BuiltinCommands.reapply(session2, structure, st)
// SessionSettings.writeSettings(ex.currentRef, session2, ex.session.original, ex.structure)
SessionSettings.saveAllSettings(st1)
}
lazy val root = Project("root", file(".")) settings(
commands += UpdateK1
)
}
// vim: set ts=4 sw=4 et:

View File

@ -0,0 +1,4 @@
> UpdateK1
$ must-mirror build.sbt build.check.1
> UpdateK1
$ must-mirror build.sbt build.check.1