Skip to content

Commit

Permalink
bugfix: Make sure everything uses didChange first
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Dec 10, 2024
1 parent c1dc156 commit 6a1cd9b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions tests/slow/src/test/scala/tests/bazel/BazelLspSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class BazelLspSuite
BazelBuildLayout(workspaceLayout, V.bazelScalaVersion, bazelVersion)
)
_ <- server.didOpen("Hello.scala")
_ <- server.didSave("Hello.scala") { _ =>
_ <- server.didChange("Hello.scala") { _ =>
"""|package examples.scala3
|
|sealed trait A
Expand All @@ -251,6 +251,7 @@ class BazelLspSuite
|}
|""".stripMargin
}
_ <- server.didSave("Hello.scala")(identity)
_ = assertNoDiff(
server.client.workspaceDiagnostics,
"""|Hello.scala:11:3: warning: match may not be exhaustive.
Expand All @@ -262,12 +263,13 @@ class BazelLspSuite
|""".stripMargin,
)
// warnings should not disappear after updating
_ <- server.didSave("Hello.scala") { text =>
_ <- server.didChange("Hello.scala") { text =>
s"""|$text
|
|class Additional
|""".stripMargin
}
_ <- server.didSave("Hello.scala")(identity)
_ = assertNoDiff(
server.client.workspaceDiagnostics,
"""|Hello.scala:11:3: warning: match may not be exhaustive.
Expand Down
1 change: 1 addition & 0 deletions tests/unit/src/main/scala/tests/TestingServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ final case class TestingServer(
val abspath = toPath(filename)
val oldText = abspath.toInputFromBuffers(buffers).text
val newText = fn(oldText)
buffers.put(abspath, newText)
didChange(filename, newText)
}

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/src/test/scala/tests/DiagnosticsLspSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,10 @@ class DiagnosticsLspSuite extends BaseLspSuite("diagnostics") {
| ^^
|""".stripMargin,
)
_ <- server.didSave("a/src/main/scala/a/A.scala")(
_ <- server.didChange("a/src/main/scala/a/A.scala")(
_.replace("val n: Int = \"\"", "val n: Int = \" ")
)
_ <- server.didSave("a/src/main/scala/a/A.scala")(identity)
_ = assertNoDiff(
client.workspaceDiagnostics,
"""|a/src/main/scala/a/A.scala:2:16: error: unclosed string literal
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/src/test/scala/tests/DidFocusLspSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,10 @@ class DidFocusWhileCompilingLspSuite
|""".stripMargin
}
_ = fakeTime.elapseSeconds(10)
_ <- server.didSave("a/src/main/scala/a/A.scala")(
_ <- server.didChange("a/src/main/scala/a/A.scala")(
_.replace("1", "\"\"")
)
_ <- server.didSave("a/src/main/scala/a/A.scala")(identity)
_ = assertNoDiff(
client.workspaceDiagnostics,
xMismatch,
Expand Down

0 comments on commit 6a1cd9b

Please sign in to comment.