lsp: made TextDocumentEdit accept optional versions;
authorThomas Lindae <thomas.lindae@in.tum.de>
Sun, 30 Jun 2024 15:22:36 +0200
changeset 81065 37590e377db6
parent 81064 e81864b37183
child 81066 18c98588388d
lsp: made TextDocumentEdit accept optional versions;
src/Tools/VSCode/src/lsp.scala
--- a/src/Tools/VSCode/src/lsp.scala	Sun Jun 30 15:32:51 2024 +0200
+++ b/src/Tools/VSCode/src/lsp.scala	Sun Jun 30 15:22:36 2024 +0200
@@ -328,11 +328,15 @@
     def json: JSON.T = JSON.Object("range" -> Range(range), "newText" -> new_text)
   }
 
-  sealed case class TextDocumentEdit(file: JFile, version: Long, edits: List[TextEdit]) {
+  sealed case class TextDocumentEdit(file: JFile, version: Option[Long], edits: List[TextEdit]) {
     def json: JSON.T =
       JSON.Object(
-        "textDocument" -> JSON.Object("uri" -> Url.print_file(file), "version" -> version),
-        "edits" -> edits.map(_.json))
+        "textDocument" -> (
+          JSON.Object("uri" -> Url.print_file(file)) ++
+          JSON.optional("version" -> version)
+        ),
+        "edits" -> edits.map(_.json)
+      )
   }
 
   object WorkspaceEdit {