]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
shane/mdf: to avoid if location (result) of defDecl was null
authorshane.xb.qian <shane.qian@foxmail.com>
Fri, 11 Mar 2022 02:22:16 +0000 (10:22 +0800)
committershane.xb.qian <shane.qian@foxmail.com>
Fri, 11 Mar 2022 02:22:16 +0000 (10:22 +0800)
autoload/lsp/handlers.vim

index 89b8ddf6ce3c05f9325dabbd29f64bda75f0d284..59abfb6b56060011bd46a11d6a7a151cc1f61dfe 100644 (file)
@@ -133,14 +133,14 @@ enddef
 # Result: Location | Location[] | LocationLink[] | null
 def ProcessDefDeclReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
   var location: dict<any>
-  if reply.result->type() == v:t_list
-    if !reply.result->empty()
-      location = reply.result[0]
-    else
-      location = {}
-    endif
-  else
+  if reply.result->type() == v:t_list && !reply.result->empty() && reply.result[0]->type() == v:t_dict
+    location = reply.result[0]
+  elseif reply.result->type() == v:t_dict
+    # not sure if there possible 'dict' type of 'result' but just in case
     location = reply.result
+  else
+    # cannot assign 'null' to 'location' and/so all else cases assign '{}'
+    location = {}
   endif
 
   symbol.GotoSymbol(lspserver, location, req.method)