Skip to content

Commit a79931d

Browse files
mattnhrsh7th
andauthored
Ignore error of prop_add/prop_remove (#721)
Some language server send diagnostics which send wrong locations. Co-authored-by: hrsh7th <[email protected]>
1 parent f364102 commit a79931d

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

autoload/lsp/ui/vim/diagnostics/textprop.vim

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,15 @@ function! s:clear_all_highlights() abort
7979

8080
for l:bufnr in range(1, bufnr('$'))
8181
if bufexists(l:bufnr) && bufloaded(l:bufnr)
82-
call prop_remove({
83-
\ 'type': l:prop_type,
84-
\ 'bufnr': l:bufnr,
85-
\ 'all': v:true,
86-
\ }, 1, len(getbufline(l:bufnr, 1, '$')))
82+
try
83+
call prop_remove({
84+
\ 'type': l:prop_type,
85+
\ 'bufnr': l:bufnr,
86+
\ 'all': v:true,
87+
\ }, 1, len(getbufline(l:bufnr, 1, '$')))
88+
catch
89+
call lsp#log('clear_all_highlights', v:exception)
90+
endtry
8791
endif
8892
endfor
8993

@@ -103,11 +107,15 @@ function! s:clear_highlights(server_name, path) abort
103107

104108
for l:severity in keys(s:severity_sign_names_mapping)
105109
let l:prop_type = s:get_prop_type(a:server_name, l:severity)
106-
call prop_remove({
107-
\ 'type': l:prop_type,
108-
\ 'bufnr': l:bufnr,
109-
\ 'all': v:true,
110-
\ }, 1, len(getbufline(l:bufnr, 1, '$')))
110+
try
111+
call prop_remove({
112+
\ 'type': l:prop_type,
113+
\ 'bufnr': l:bufnr,
114+
\ 'all': v:true,
115+
\ }, 1, len(getbufline(l:bufnr, 1, '$')))
116+
catch
117+
call lsp#log('clear_highlights', v:exception)
118+
endtry
111119
endfor
112120
endfunction
113121

@@ -121,12 +129,16 @@ function! s:place_highlights(server_name, path, diagnostics) abort
121129
let [l:end_line, l:end_col] = lsp#utils#position#_lsp_to_vim(l:bufnr, l:item['range']['end'])
122130

123131
let l:prop_type = s:get_prop_type(a:server_name, get(l:item, 'severity', 1))
124-
call prop_add(l:start_line, l:start_col, {
125-
\ 'end_lnum': l:end_line,
126-
\ 'end_col': l:end_col,
127-
\ 'bufnr': l:bufnr,
128-
\ 'type': l:prop_type,
129-
\ })
132+
try
133+
call prop_add(l:start_line, l:start_col, {
134+
\ 'end_lnum': l:end_line,
135+
\ 'end_col': l:end_col,
136+
\ 'bufnr': l:bufnr,
137+
\ 'type': l:prop_type,
138+
\ })
139+
catch
140+
call lsp#log('place_highlights', v:exception)
141+
endtry
130142
endfor
131143
endif
132144
endfunction

0 commit comments

Comments
 (0)