]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Prevent raising errors when highlight arrive for deleted lines
authorAndreas Louv <andreas@louv.dk>
Tue, 18 Apr 2023 19:48:08 +0000 (21:48 +0200)
committerAndreas Louv <andreas@louv.dk>
Tue, 18 Apr 2023 19:48:58 +0000 (21:48 +0200)
This is the same problem that was fixed in #193 (3661dc0) as the
highlight also arrive asynchronous.

autoload/lsp/lspserver.vim

index 42121bc730f6f9087d3cdb684f2348f0a40d8d93..69af662bb7a921a9852ab8a038be795d97f01398 100644 (file)
@@ -896,12 +896,17 @@ def DocHighlightReply(lspserver: dict<any>, docHighlightReply: any,
       # textual reference
       propName = 'LspTextRef'
     endif
-    prop_add(docHL.range.start.line + 1,
-               util.GetLineByteFromPos(bnr, docHL.range.start) + 1,
-               {end_lnum: docHL.range.end.line + 1,
-                 end_col: util.GetLineByteFromPos(bnr, docHL.range.end) + 1,
-                 bufnr: bnr,
-                 type: propName})
+    try
+      prop_add(docHL.range.start.line + 1,
+                  util.GetLineByteFromPos(bnr, docHL.range.start) + 1,
+                  {end_lnum: docHL.range.end.line + 1,
+                    end_col: util.GetLineByteFromPos(bnr, docHL.range.end) + 1,
+                    bufnr: bnr,
+                    type: propName})
+    catch /E966\|E964/ # Invalid lnum | Invalid col
+      # Highlight arrive asynchronous and the document changed while they wore
+      # send.
+    endtry
   endfor
 enddef