From 4d6547e4e9af7a790b2dfc4d0b8e8a09fabebcb9 Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Fri, 21 Apr 2023 20:56:41 -0700 Subject: [PATCH] Adding inlay hints results in error if the text is modified --- autoload/lsp/inlayhints.vim | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) 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 -- 2.48.1