diff --git a/CHANGELOG.md b/CHANGELOG.md index c7345c14..d8d50518 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Enable incremental sync by default. - Enable apply edit by default. - Improve the preview height for hover text which has few lines but they wrap. +- Bug Fix: Include diagnostics for the current line with code actions requests. # 0.2.10 diff --git a/autoload/lsc/diagnostics.vim b/autoload/lsc/diagnostics.vim index 086160f8..74463165 100644 --- a/autoload/lsc/diagnostics.vim +++ b/autoload/lsc/diagnostics.vim @@ -22,7 +22,8 @@ function! s:Convert(diagnostic) abort let message = message.' ['.a:diagnostic.code.']' endif return {'group': group, 'message': message, 'type': type, - \ 'ranges': lsc#convert#rangeToHighlights(a:diagnostic.range)} + \ 'ranges': lsc#convert#rangeToHighlights(a:diagnostic.range), + \ 'lsp': a:diagnostic} endfunction function! lsc#diagnostics#clean(filetype) abort @@ -235,3 +236,15 @@ function! lsc#diagnostics#underCursor() abort endfor return closest_diagnostic endfunction + +" Returns the original LSP representation of diagnostics on a line. +function! lsc#diagnostics#forLine(file, line) abort + let l:result = [] + let l:file_diagnostics = lsc#diagnostics#forFile(a:file) + if has_key(l:file_diagnostics, a:line) + for l:diagnostic in l:file_diagnostics[a:line] + call add(l:result, l:diagnostic.lsp) + endfor + endif + return l:result +endfunction diff --git a/autoload/lsc/edit.vim b/autoload/lsc/edit.vim index 9018070a..ba16f126 100644 --- a/autoload/lsc/edit.vim +++ b/autoload/lsc/edit.vim @@ -31,7 +31,8 @@ function! s:TextDocumentRangeParams() abort \ 'range': { \ 'start': {'line': line('.') - 1, 'character': col('.') - 1}, \ 'end': {'line': line('.') - 1, 'character': col('.')}}, - \ 'context': {'diagnostics': []} + \ 'context': {'diagnostics': + \ lsc#diagnostics#forLine(expand('%:p'), line('.'))} \} endfunction