From: Andreas Louv Date: Tue, 18 Apr 2023 19:48:08 +0000 (+0200) Subject: Prevent raising errors when highlight arrive for deleted lines X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=c7e7876d221487bb0686314bd12c3119bf75b83f;p=vim-lsp.git Prevent raising errors when highlight arrive for deleted lines This is the same problem that was fixed in #193 (3661dc0) as the highlight also arrive asynchronous. --- diff --git a/autoload/lsp/lspserver.vim b/autoload/lsp/lspserver.vim index 42121bc..69af662 100644 --- a/autoload/lsp/lspserver.vim +++ b/autoload/lsp/lspserver.vim @@ -896,12 +896,17 @@ def DocHighlightReply(lspserver: dict, 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