]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Adding inlay hints results in error if the text is modified
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sat, 22 Apr 2023 03:56:41 +0000 (20:56 -0700)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Sat, 22 Apr 2023 03:56:41 +0000 (20:56 -0700)
autoload/lsp/inlayhints.vim

index 3d3384b8d352ca9c3298a982ad7c44ec5f0e3064..b03e1b785f57df7d9dd0b27429b8b7d56af7393b 100644 (file)
@@ -44,13 +44,19 @@ export def InlayHintsReply(lspserver: dict<any>, 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