From: Yegappan Lakshmanan Date: Sat, 22 Apr 2023 03:56:41 +0000 (-0700) Subject: Adding inlay hints results in error if the text is modified X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=4d6547e4e9af7a790b2dfc4d0b8e8a09fabebcb9;p=vim-lsp.git Adding inlay hints results in error if the text is modified --- diff --git a/autoload/lsp/inlayhints.vim b/autoload/lsp/inlayhints.vim index 3d3384b..b03e1b7 100644 --- a/autoload/lsp/inlayhints.vim +++ b/autoload/lsp/inlayhints.vim @@ -44,13 +44,19 @@ export def InlayHintsReply(lspserver: dict, inlayHints: any) endif var kind = hint->has_key('kind') ? hint.kind->string() : '1' - if kind == "'type'" || kind == '1' - prop_add(hint.position.line + 1, hint.position.character + 1, - {type: 'LspInlayHintsType', text: label, bufnr: bufnum}) - elseif kind == "'parameter'" || kind == '2' - prop_add(hint.position.line + 1, hint.position.character + 1, - {type: 'LspInlayHintsParam', text: label, bufnr: bufnum}) - endif + try + if kind == "'type'" || kind == '1' + prop_add(hint.position.line + 1, hint.position.character + 1, + {type: 'LspInlayHintsType', text: label, bufnr: bufnum}) + elseif kind == "'parameter'" || kind == '2' + prop_add(hint.position.line + 1, hint.position.character + 1, + {type: 'LspInlayHintsParam', text: label, bufnr: bufnum}) + endif + catch /E966\|E964/ # Invalid lnum | Invalid col + # Inlay hints replies arrive asynchronously and the document might have + # been modified in the mean time. As the reply is stale, ignore invalid + # line number and column number errors. + endtry endfor enddef