]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Access the save key in textDocumentSync only if it is a Dict
authorYegappan Lakshmanan <yegappan@yahoo.com>
Fri, 6 Oct 2023 19:11:39 +0000 (12:11 -0700)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Fri, 6 Oct 2023 19:11:39 +0000 (12:11 -0700)
autoload/lsp/lspserver.vim

index 40bc1453cf0de540b340934e53280ea3647a6194..315ba27b58f4b21d696f762661f3669c7f53fd82 100644 (file)
@@ -908,8 +908,13 @@ def DidSaveFile(lspserver: dict<any>, bnr: number): void
   # Params: DidSaveTextDocumentParams
   var params: dict<any> = {textDocument: {uri: util.LspBufnrToUri(bnr)}}
 
-  if lspserver.caps.textDocumentSync->get("save", {})->get("includeText", v:false)
-    params.text = bnr->getbufline(1, '$')->join("\n") .. "\n"
+  if lspserver.caps.textDocumentSync->type() == v:t_dict
+      && lspserver.caps.textDocumentSync->has_key('save')
+    if lspserver.caps.textDocumentSync.save->type() == v:t_dict
+       && lspserver.caps.textDocumentSync.save->has_key('includeText')
+       && lspserver.caps.textDocumentSync.save.includeText
+      params.text = bnr->getbufline(1, '$')->join("\n") .. "\n"
+    endif
   endif
 
   lspserver.sendNotification('textDocument/didSave', params)