From 14f368447a2ad71bb94b83cac6f2c4d413c3454f Mon Sep 17 00:00:00 2001 From: Billie Cleek Date: Sun, 5 Jul 2020 21:41:59 -0700 Subject: [PATCH] lsp: ignore nulls in definition and type definition handlers Fixes #2949 --- autoload/go/lsp.vim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/autoload/go/lsp.vim b/autoload/go/lsp.vim index 395567ca3b..ba99681a6b 100644 --- a/autoload/go/lsp.vim +++ b/autoload/go/lsp.vim @@ -576,6 +576,10 @@ function! go#lsp#Definition(fname, line, col, handler) abort endfunction function! s:definitionHandler(next, msg) abort dict + if a:msg is v:null || len(a:msg) == 0 + return + endif + " gopls returns a []Location; just take the first one. let l:msg = a:msg[0] let l:args = [[printf('%s:%d:%d: %s', go#path#FromURI(l:msg.uri), l:msg.range.start.line+1, go#lsp#lsp#PositionOf(getline(l:msg.range.start.line+1), l:msg.range.start.character), 'lsp does not supply a description')]] @@ -598,6 +602,10 @@ function! go#lsp#TypeDef(fname, line, col, handler) abort endfunction function! s:typeDefinitionHandler(next, msg) abort dict + if a:msg is v:null || len(a:msg) == 0 + return + endif + " gopls returns a []Location; just take the first one. let l:msg = a:msg[0] let l:args = [[printf('%s:%d:%d: %s', go#path#FromURI(l:msg.uri), l:msg.range.start.line+1, go#lsp#lsp#PositionOf(getline(l:msg.range.start.line+1), l:msg.range.start.character), 'lsp does not supply a description')]]