autoload/lsp/inlayhints.vim | 20 +++++++++++++------- diff --git a/autoload/lsp/inlayhints.vim b/autoload/lsp/inlayhints.vim index 3d3384b8d352ca9c3298a982ad7c44ec5f0e3064..b03e1b785f57df7d9dd0b27429b8b7d56af7393b 100644 --- a/autoload/lsp/inlayhints.vim +++ b/autoload/lsp/inlayhints.vim @@ -44,13 +44,19 @@ label = hint.label 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