Skip to content

Commit 01a5a31

Browse files
doriathprabirshrestha
authored andcommitted
Improve name of diagnostic variables. (#348)
Use 'diagnostic' (singular) when variable refers to one Diagnostic object and use 'diagnostics' (plural) when it is a list of diagnostics.
1 parent 3121f0a commit 01a5a31

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

autoload/lsp/ui/vim/diagnostics.vim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ function! lsp#ui#vim#diagnostics#document_diagnostics() abort
5151
endif
5252
endfunction
5353

54+
" Returns a diagnostic object, or empty dictionary if no diagnostics are available.
55+
"
56+
" Note: Consider renaming this method (s/diagnostics/diagnostic) to make
57+
" it clear that it returns just one diagnostic, not a list.
5458
function! lsp#ui#vim#diagnostics#get_diagnostics_under_cursor() abort
5559
let l:diagnostics = s:get_all_buffer_diagnostics()
5660
if !len(l:diagnostics)
@@ -60,7 +64,7 @@ function! lsp#ui#vim#diagnostics#get_diagnostics_under_cursor() abort
6064
let l:line = line('.')
6165
let l:col = col('.')
6266

63-
let l:closest_diagnostics = {}
67+
let l:closest_diagnostic = {}
6468
let l:closest_distance = -1
6569

6670
for l:diagnostic in l:diagnostics
@@ -72,13 +76,13 @@ function! lsp#ui#vim#diagnostics#get_diagnostics_under_cursor() abort
7276
if l:line == l:start_line
7377
let l:distance = abs(l:start_col - l:col)
7478
if l:closest_distance < 0 || l:distance < l:closest_distance
75-
let l:closest_diagnostics = l:diagnostic
79+
let l:closest_diagnostic = l:diagnostic
7680
let l:closest_distance = l:distance
7781
endif
7882
endif
7983
endfor
8084

81-
return l:closest_diagnostics
85+
return l:closest_diagnostic
8286
endfunction
8387

8488
function! lsp#ui#vim#diagnostics#next_error() abort

0 commit comments

Comments
 (0)